The frame of a docs site
A header, a sidebar of pages, the content, an on-this-page aside and a footer, laid out by props: how wide the page runs, where the sidebar docks (the header and the footer move with it) and where the aside sits. Any combination holds. The sidebar sticks below the header and scrolls on its own, the aside gives way on a laptop, and on a tablet or phone the header's one menu carries the sidebar's pages.
Live
The docs block, npx rift-ds init block docs: a full-width header over a sidebar docked to the window's edge.
Layout levers
Every lever is a prop on SiteLayout or, for the room a docked panel takes, a custom property on it, so a swap is one value changed in one place. A SideNav in the sidebar hangs by its own text inset, so its words line up with the header's brand, and a host that narrows the page itself (padding on the body for a docked chat) moves the edge aside with --ds-site-layout-aside-inset. The widths read the shell recipe's width axis, the same one AppLayout and the templates read, apart from any shell mode.
| Prop or property | Values | What it sets |
|---|---|---|
width | contained (default), full | How wide the columns run: centred at 1440px, or edge to edge with the gutter |
containedWidth | narrow, default (default), wide | The contained width's step: 1200px, 1440px or 1680px, followed by the header and the footer |
headerWidth | contained, full | The header bar's width; moves with the dock (full when edge-docked, the page width beside the content), set only to break the pairing |
footerWidth | contained, full | The footer row's width; moves with the header, set only to break the pairing |
sidebarDock | content (default), edge | The sidebar as the row's first column, or docked to the window's start edge behind a hairline; the header and the footer move with it |
asidePlacement | column (default), edge | The aside as a column after the content, or pinned to the window's end edge as AnchorNav's floating minimap |
readingWidth | true, false (default) | The main column held to about 75 characters, centred, while the page is contained |
--ds-site-layout-edge-gutter | a length | The side gutter of a frame that reaches the window's edges, from 960px up; 32px by default |
--ds-site-layout-aside-inset | a length | The edge aside's distance from the window's end, for a host that narrows the page itself (padding on the body for a docked chat) |
--ds-site-layout-reserve-end | a length, 0 by default | Room the frame gives up at its end edge for a docked panel, such as a chat; an edge aside moves in with it |
<SiteLayout
width="contained"
sidebarDock="edge"
asidePlacement="column"
readingWidth
header={<SiteHeader brand="Acme" sections={sections} foldBelow="tablet" />}
sidebar={<SideNav items={pages} size="compact" scrollable currentHref={path} />}
aside={<AnchorNav fromHeadings={{ root: '#main' }} />}
footer={<SiteFooter columns={columns} />}
>
<article>…</article>
</SiteLayout>Responsive
Below 1152px a column aside gives way. Below 960px the sidebar and an edge aside leave the page and the content takes the header's gutter. Give each SiteHeader section its pages as drawerItems and set foldBelow="tablet", so the header folds at the same step and its menu carries the sidebar's pages: a reader has one menu, never two.
Alternatives
- Use App layout instead when the page is an app screen with a rail of tools rather than a site of pages.
Props
Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
children* | ReactNode | The page's main content: the article, the page. | |
header | ReactNode | The top bar, usually a SiteHeader. A SiteHeader given no `width` of its
own follows `headerWidth`, so the bar lines up with the page below it. | |
sidebar | ReactNode | The navigation column, usually a scrollable SideNav: the wide-screen
form of the site's sub-navigation. Sticks below the header; below
960px it leaves the page, and the header's own menu carries the same
pages (give each SiteHeader section its `drawerItems`, and set the
header's `foldBelow="tablet"` so it folds at the same step), so a
reader has one menu, never two. | |
aside | ReactNode | The column after the content, usually an AnchorNav reading the page's headings. Gives way below 1152px in the `column` placement. | |
asidePlacement | "column" | "edge" | 'column' | Where the aside sits. `column` gives it a column of its own after the
content. `edge` pins it to the window's end edge, centred on the
height, and gives the content the room: the place for AnchorNav's
`floating` variant, a minimap that opens on hover or focus. Hidden
below 960px in either. |
footer | ReactNode | The bottom of the site, usually a SiteFooter. | |
width | "contained" | "full" | 'contained' | How wide the page runs, the shell recipe's width axis. `contained`
centres the columns at the contained width (1440px, or the nearest
`--ds-shell-contained-width`); `full` runs them edge to edge, the side
gutter aside. |
containedWidth | "default" | "narrow" | "wide" | 'default' | The contained width's step, for a page a level narrower or wider than
the default: `narrow` (1200px, a 1080px article beside an edge-docked sidebar), `default` (1440px) or `wide` (1680px).
The header and the footer follow it when contained. With the sidebar
docked to the edge, the step caps the room after the sidebar; docked to
the content, it caps the sidebar and the content together. |
headerWidth | "contained" | "full" | sidebarDock === 'edge' ? 'full' : width | How wide the header's bar runs, for a SiteHeader that sets no `width`
of its own. It moves with the sidebar's dock: `full` when the sidebar
docks to the window's edge (so the brand sits over the sidebar, flush
with the same edge), the page's `width` when it docks beside the
content. Set it only to break that pairing. |
footerWidth | "contained" | "full" | sidebarDock === 'edge' ? 'full' : width | How wide the footer's row runs. It moves with the header: `full` when
the sidebar docks to the window's edge, the page's `width` when it
docks beside the content, so the top and the bottom of the site always
agree. Set it only to break that pairing. |
sidebarDock | "content" | "edge" | 'content' | Where the sidebar sits. `content` keeps it in the page's row, beside the
content, so a contained page centres all three columns together. `edge`
docks it to the window's start edge behind a hairline, and the content
and aside are laid out (and contained) in the room after it. |
readingWidth | boolean | false | Hold the main column to a reading width (about 75 characters of body
text, centred in its column) while the page is contained. A full-width page lets the content run the whole column.
`--ds-site-layout-reading-width` sets the measure. |
mainId | string | 'main' | The id of the main region, the skip link's target. |
skipLinkLabel | string | 'Skip to content' | The skip link's text, the page's first stop. Pass an empty string for none. |
sidebarLabel | string | 'Pages' | Accessible name of the sidebar's navigation landmark. |
asideLabel | string | 'On this page' | Accessible name of the aside's complementary landmark. |
className | string | '' | Additional CSS classes |
Keys
A frame: its slots own their keys, and its skip link is a native link. Those keys belong to the platform, so no test of this library presses them.
// From the npm package
import { SiteLayout } from 'rift-ds/components/SiteLayout/SiteLayout';
// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/site-layout.json1.4 kB gzipped, with everything it imports. Peer dependencies are not counted.
For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.