Layout
Use Layout for the frame of a page or an app: a header, a sider for navigation, the content and a footer, with the whole page scrolling or each pane scrolling on its own. To line up a few elements inside the content, use Flex or Grid; for a panel that comes and goes over the page, use Drawer.
LayoutSideronly sits beside the content inside aLayoutwithhasSider; anywhere else it stacks like a header, with a warning.- With
position="absolute"the layout fills its nearest positioned parent, so that parent needs a height: the window for a whole app, or a box with a set height.
Layout is the frame of a page: LayoutHeader, LayoutContent and LayoutFooter stack in a column, and with hasSider a LayoutSider sits beside the content. Each part renders its landmark by default (header, aside, main, footer); change it with as.
There are two ways to scroll:
- The page scrolls (
position="static", the default). The layout grows with its content and never clips, soposition="sticky"headers and siders stick to the window. Use it for documents and docs sites. - The panes scroll (
position="absolute"). The layout fills its positioned parent, and the content, each sider and any nested layout scroll on their own. Use it for app shells.
#Demos
#Basic
A header, content and footer in a column; hasSider puts a sider beside them. bordered draws a rule on the side that faces the content.
#App shell
position="absolute" fills the nearest positioned parent. Give that parent a height (here a 360px box; for a whole app, the window). The header and footer keep their height and the panes between them scroll.
Message 1. The header and footer stay put; the sider and this pane scroll on their own.
Message 2. The header and footer stay put; the sider and this pane scroll on their own.
Message 3. The header and footer stay put; the sider and this pane scroll on their own.
Message 4. The header and footer stay put; the sider and this pane scroll on their own.
Message 5. The header and footer stay put; the sider and this pane scroll on their own.
Message 6. The header and footer stay put; the sider and this pane scroll on their own.
Message 7. The header and footer stay put; the sider and this pane scroll on their own.
Message 8. The header and footer stay put; the sider and this pane scroll on their own.
Message 9. The header and footer stay put; the sider and this pane scroll on their own.
Message 10. The header and footer stay put; the sider and this pane scroll on their own.
Message 11. The header and footer stay put; the sider and this pane scroll on their own.
Message 12. The header and footer stay put; the sider and this pane scroll on their own.
Message 13. The header and footer stay put; the sider and this pane scroll on their own.
Message 14. The header and footer stay put; the sider and this pane scroll on their own.
Message 15. The header and footer stay put; the sider and this pane scroll on their own.
Message 16. The header and footer stay put; the sider and this pane scroll on their own.
#Scrollbar
A sider, and the content of an absolute layout, scroll in a ScrollArea. Pass it props with scrollAreaProps, here trigger: "none" to always show the scrollbars, and pad the content through its contentClassName so the padding scrolls too. nativeScrollbar uses the browser’s scrollbar instead.
Message 1. With trigger="none" the scrollbars show without hovering.
Message 2. With trigger="none" the scrollbars show without hovering.
Message 3. With trigger="none" the scrollbars show without hovering.
Message 4. With trigger="none" the scrollbars show without hovering.
Message 5. With trigger="none" the scrollbars show without hovering.
Message 6. With trigger="none" the scrollbars show without hovering.
Message 7. With trigger="none" the scrollbars show without hovering.
Message 8. With trigger="none" the scrollbars show without hovering.
Message 9. With trigger="none" the scrollbars show without hovering.
Message 10. With trigger="none" the scrollbars show without hovering.
Message 11. With trigger="none" the scrollbars show without hovering.
Message 12. With trigger="none" the scrollbars show without hovering.
Message 13. With trigger="none" the scrollbars show without hovering.
Message 14. With trigger="none" the scrollbars show without hovering.
Message 15. With trigger="none" the scrollbars show without hovering.
Message 16. With trigger="none" the scrollbars show without hovering.
#Collapse
showTrigger adds a toggle on the sider’s edge. collapseMode="width" narrows the content to collapsedWidth; the default transform keeps the content’s width and slides it under the edge.
Press the button on the sider's edge. With collapseMode="width" the content narrows to collapsedWidth, so only the icons stay.
#Right sider, controlled
A sider after the content with placement="right" borders and toggles on its left. showTrigger="bar" draws a bar beside it. Control it with collapsed and onUpdateCollapsed; collapsedWidth={0} with showCollapsedContent={false} hides it completely.
#Docs site
The page scrolls (the frame stands in for the window). The header is sticky; both siders are sticky 48px below it, as tall as the window minus that offset, and scroll on their own when their links don’t fit. hideBelow hides a sider when the window is narrower than a Grid breakpoint: the page list below m, the outline below l.
When to use
The page scrolls as a whole. The header sticks to the top and both siders stick below it, each as tall as the window that is left.
Below 1024px the pages sider hides, and below 1280px the outline does.
Demos
The page scrolls as a whole. The header sticks to the top and both siders stick below it, each as tall as the window that is left.
Below 1024px the pages sider hides, and below 1280px the outline does.
Scrolling
The page scrolls as a whole. The header sticks to the top and both siders stick below it, each as tall as the window that is left.
Below 1024px the pages sider hides, and below 1280px the outline does.
Accessibility
The page scrolls as a whole. The header sticks to the top and both siders stick below it, each as tall as the window that is left.
Below 1024px the pages sider hides, and below 1280px the outline does.
API
The page scrolls as a whole. The header sticks to the top and both siders stick below it, each as tall as the window that is left.
Below 1024px the pages sider hides, and below 1280px the outline does.
#Layout Props
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
as | div | header | footer | aside | main | nav | section | article | div | The element to render. | Unreleased |
hasSider | boolean | false | Lays the children out in a row. Set it when a LayoutSider is inside. | Unreleased |
position | static | absolute | static | static flows with the page; absolute fills the positioned parent and lets the panes scroll. Nested layouts inherit absolute’s scrolling. | Unreleased |
#LayoutHeader, LayoutFooter Props
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
as | LayoutElement | header / footer | The element to render. | Unreleased |
bordered | boolean | false | Draws a rule on the side that faces the content. | Unreleased |
position | static | sticky | static | sticky keeps it at the top (header) or bottom (footer) while the page scrolls. | Unreleased |
stickyOffset | number | string | 0 | Distance from the edge it sticks to; numbers are px. | Unreleased |
#LayoutContent Props
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
as | LayoutElement | main | The element to render. | Unreleased |
nativeScrollbar | boolean | false | Scroll with the browser’s scrollbar instead of a ScrollArea. | Unreleased |
onScroll | (event) => void | undefined | Called when the scrolling element scrolls. | Unreleased |
scrollAreaProps | LayoutScrollAreaProps | undefined | Props for the ScrollArea. | Unreleased |
scrollRef | Ref<HTMLElement> | undefined | The scrolling element (the content itself, or its ScrollArea), for scrollTo. | Unreleased |
#LayoutSider Props
| Name | Type | Default | Description | Version |
|---|---|---|---|---|
as | LayoutElement | aside | The element to render. | Unreleased |
bordered | boolean | false | Draws a rule on the side that faces the content. | Unreleased |
collapsed | boolean | undefined | Collapsed (controlled). | Unreleased |
collapsedWidth | number | string | 48 | Width when collapsed; numbers are px. | Unreleased |
collapseMode | width | transform | transform | width narrows the content; transform keeps its width and slides it out. | Unreleased |
contentClassName | string | undefined | Class of the element that wraps the children. | Unreleased |
contentStyle | CSSProperties | undefined | Style of the element that wraps the children. | Unreleased |
defaultCollapsed | boolean | false | Collapsed at first (uncontrolled). | Unreleased |
hideBelow | s | m | l | xl | undefined | Hides the sider when the window is narrower than the breakpoint (640, 1024, 1280, 1536px). | Unreleased |
nativeScrollbar | boolean | false | Scroll with the browser’s scrollbar instead of a ScrollArea. | Unreleased |
onScroll | (event) => void | undefined | Called when the scrolling element scrolls. | Unreleased |
onUpdateCollapsed | (collapsed: boolean) => void | undefined | Called with the new state when the trigger is pressed. | Unreleased |
placement | left | right | left | Which side of the content it sits on; the border and trigger face the content. Put a right sider after the content. | Unreleased |
position | static | sticky | static | sticky keeps it in view while the page scrolls. Ignored inside an absolute layout, where it scrolls anyway. | Unreleased |
scrollAreaProps | LayoutScrollAreaProps | undefined | Props for the ScrollArea. | Unreleased |
scrollRef | Ref<HTMLElement> | undefined | The scrolling element, for scrollTo. | Unreleased |
showCollapsedContent | boolean | true | Keeps the content visible while collapsed. | Unreleased |
showTrigger | boolean | button | bar | false | Shows a collapse toggle: a button on the edge (true, button) or a bar beside it. | Unreleased |
stickyOffset | number | string | 0 | Distance from the top it sticks to; numbers are px. | Unreleased |
triggerLabel | string | locale’s “Toggle sidebar” | Accessible name of the trigger. | Unreleased |
width | number | string | 272 | Width when expanded; numbers are px. | Unreleased |
Every part forwards native attributes and ref to its root element.
#Notes
- Header, footer and siders never use
position: absolute. In an app shell they are flex items and the panes scroll; in a page they can besticky. Layoutitself does not scroll: the content or a sider scrolls, andscrollRef/onScrollreach it. A nestedLayoutinside anabsoluteone still scrolls natively when its own children overflow.- The side of a sider is set on
LayoutSiderwithplacement, so one layout can have a sider on each side. - Themes decide the colors. To act when a sider finishes opening or closing, listen for
transitionendon the sider.