Preview loads on approachPreview loads on approach
Exact source · layout-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {
Layout,
LayoutHeader,
LayoutContent,
LayoutFooter,
LayoutPanel,
HStack,
VStack,
} from '@astryxdesign/core/Layout';
import {Section} from '@astryxdesign/core/Section';
import {Text, Heading} from '@astryxdesign/core/Text';
import {Button} from '@astryxdesign/core/Button';
import {Badge} from '@astryxdesign/core/Badge';
import {List, ListItem} from '@astryxdesign/core/List';
export default function LayoutShowcase() {
return (
<Section padding={4}>
<Layout
height="fill"
header={
<LayoutHeader hasDivider>
<HStack gap={2} vAlign="center">
<Heading level={4}>Projects</Heading>
<Badge variant="info" label="3 active" />
</HStack>
</LayoutHeader>
}
start={
<LayoutPanel hasDivider width={140}>
<List>
<ListItem label="Dashboard" isSelected />
<ListItem label="Analytics" />
<ListItem label="Settings" />
</List>
</LayoutPanel>
}
content={
<LayoutContent>
<VStack gap={2}>
<Heading level={5}>Welcome back</Heading>
<Text type="body" color="secondary">
You have 3 active projects and 2 pending reviews.
</Text>
</VStack>
</LayoutContent>
}
footer={
<LayoutFooter hasDivider>
<HStack gap={2} hAlign="end">
<Button label="New Project" variant="primary">
New Project
</Button>
</HStack>
</LayoutFooter>
}
/>
</Section>
);
}
Usage
Layout is a general five-slot primitive for arranging header, start, content, end, and footer regions within a page or bounded container. AppShell owns the page shell and app-wide navigation behavior; use HStack or VStack for simple directional stacking.
Use Layout when content needs named header, start, content, end, or footer regions.
Use HStack and VStack for simple directional stacking within a content area.
Use Layout for simple stacking layouts; use HStack or VStack instead.
Use Layout as the page shell or for app-wide navigation; use AppShell for that responsibility.
Typed props
Prop
Type and behavior
content
ReactNode
Content slot (center). Accepts any ReactNode; use LayoutContent when a content region is needed. Children passed to <Layout> render here too: <Layout>{main}</Layout> is shorthand for <Layout content={main} />.
Height behavior: fill the container or grow with content.
contentWidth
SizeValue
Maximum width of the aligned content within each slot (header, content, footer, panels), centered when narrower than the available space. Without panels, LayoutContent spans the available width so its scrollbar stays at the outer edge while its children align internally to contentWidth. With exactly one panel, the panel stays aligned to the contentWidth frame while LayoutContent extends to the opposite open edge. With both panels, contentWidth includes the complete middle composition. Percentage widths—including percentage-bearing calc(), min(), max(), and clamp() values—and intrinsic widths, plus bare var(...) values, retain the constrained composition; use calc(var(...)) for a variable guaranteed to resolve to a length. Dividers stay full-bleed. Numbers are treated as pixels, strings are used as-is (e.g. 60ch). Common page widths: 640 for forms, settings, and text-focused pages; 960 for content pages and wider layouts.
padding
0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10
Padding at the layout's outer edges using the spacing scale.
defaultHasDividers
boolean
Default divider visibility for LayoutHeader and LayoutFooter children. Headers and footers that don't pass hasDivider use this value; when unset, nested layouts inherit from their parent context.
Anatomy
Layout container · required
General layout primitive that places the header, start, content, end, and footer slots.
Header · optional
Optional LayoutHeader region supplied by the caller, typically in the header slot.
Panel · optional
Optional LayoutPanel region supplied by the caller in the start or end slot.
Content area · optional
Optional LayoutContent region supplied by the caller in the content slot.
Footer · optional
Optional LayoutFooter region supplied by the caller, typically in the footer slot.