App Layout
Arrange a header, sidebars, content, and footer in one application shell.
Demos
Usage
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Workspace layout
AppLayout has IPEX styling for the header, footer, side regions, and skip link. Use the left slot for navigation. Set viewport to false when a parent supplies the height, as these embedded previews do.
<AppLayout :viewport="false" scroll="page">
<template #header>Workspace</template>
<template #left><ProjectNavigation /></template>
<ProjectList />
<template #footer>2 projects</template>
</AppLayout>
Inspector layout
Add a right region for details that belong beside the current task. The layout prop controls which regions the header and footer span.
<AppLayout :layout="{ header: 'full', footer: 'content' }">
<template #left><ProjectNavigation /></template>
<ProjectList />
<template #right><ProjectDetails /></template>
</AppLayout>
Installation
Complete the shared installation. Copy AppLayout.vue and index.ts into app/components/ui/app-layout/.
<script setup lang="ts">
import { AppLayout as Primitive } from 'akaza-ui'
import { computed, useAttrs, useTemplateRef } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import {
appLayoutVariants,
resolveAppLayoutVariants,
type AppLayoutProps,
type AppLayoutSlots,
} from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<AppLayoutProps>(), {
as: undefined,
mainAs: undefined,
layout: undefined,
scroll: undefined,
viewport: undefined,
stickyHeader: undefined,
stickyFooter: undefined,
stickySides: undefined,
stickyLeft: undefined,
stickyRight: undefined,
safeArea: undefined,
mainId: undefined,
mainLabel: undefined,
skipLink: undefined,
skipLabel: undefined,
ui: undefined,
})
defineSlots<AppLayoutSlots>()
const attrs = useAttrs()
const styles = computed(() => appLayoutVariants(resolveAppLayoutVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'root' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, ...native } = props
return native
})
const primitive = useTemplateRef<InstanceType<typeof Primitive>>('primitive')
defineExpose({
get main() {
return primitive.value!.main
},
get focusMain() {
return primitive.value!.focusMain
},
})
</script>
<template>
<component
:is="Primitive"
ref="primitive"
v-bind="{ ...primitiveProps, ...attrs }"
:ui="mergedUi"
>
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof AppLayoutSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
as | string | Component | "div" | Outer root element. |
mainAs | string | Component | "main" | Content element; use a native tag for the exposed focus helper. |
layout | AppLayoutConfig | See below | Region span and side placement. Partial objects keep defaults for omitted keys. |
scroll | "content" | "page" | "content" | Independent main scrolling or document flow. |
viewport | boolean | true | Dynamic viewport height in content mode; minimum viewport height in page mode. |
stickyHeader | boolean | false | Sticky header in page mode. |
stickyFooter | boolean | false | Sticky footer in page mode. |
stickySides | boolean | false | Sticky inline sides in page mode. |
stickyLeft | boolean | stickySides | Override stickiness for the inline left side in page mode. Explicit false disables it. |
stickyRight | boolean | stickySides | Override stickiness for the inline right side in page mode. Explicit false disables it. |
safeArea | boolean | true | Outer device safe-area padding. Consumer padding utilities can override it. |
mainId | string | Generated | Main ID and skip-link target. Keep explicit IDs unique. |
mainLabel | string | - | Accessible name on content element. |
skipLink | boolean | true | Render the keyboard skip link. |
skipLabel | string | "Skip to content" | Skip-link text, including localization. |
ui | AppLayoutUi | - | Classes for generated parts. |
Slots
All five slots receive mainId: string, resolved layout: Required<AppLayoutConfig>, and scroll: AppLayoutScroll. Slots supply content inside generated region wrappers. Omitted region slots produce no wrappers. Slot-owned controls retain their own event handlers and accessibility.