Page
Page centers the application frame, supplies responsive margins and fills at least the viewport height. A direct aside becomes a sidebar beside the content.
01Preview
A centered application frame.
02Usage
Load @dg/ui/styles.css once in the root layout.
<script>
import { Page, Header, Main, Footer, SkipLink, Heading } from "@dg/ui";
</script>
<Page lang="en">
<SkipLink />
<Header />
<Main><Heading title="Collection" /></Main>
<Footer />
</Page>
Place an aside between Header and Main for a sidebar. Page lays it out beside the content without a wrapper; the aside draws its own rules.
<script>
import { Page, Header, Main, Footer, SkipLink, Heading } from "@dg/ui";
</script>
<Page lang="en">
<SkipLink />
<Header />
<aside aria-label="Collection">
<nav aria-label="Collection subjects">
<a href="/paintings">Paintings</a>
<a href="/drawings">Drawings</a>
</nav>
</aside>
<Main><Heading title="Paintings" /></Main>
<Footer />
</Page>
<style>
/* The content's start rule closes the aside beside it. */
aside {
border-inline-start: var(--border-width) solid var(--border);
border-top: var(--border-width) solid var(--border);
}
/* Stacked above the content, the aside also draws its end rule. */
@media (--medium) {
aside {
border-inline-end: var(--border-width) solid var(--border);
}
}
</style>
03Examples
04Notes
- Native HTML attributes, DOM callbacks, class and style are forwarded to the inner page div.
langis set on the page element and selects the built-in English or French text ofSkipLink,Header,ThemeToggle,Dialog,Tabs,Cards,ErrorPageand the conversation components. Props that name content, such aslabelorplaceholder, override single entries. A nestedPagewithoutlanginherits it.- Forwarding uses native attribute types; unknown props are not supported. Pass class as a string.
- Direct frames of
PageandMaindrop their bottom rule, so each frame junction is drawn once by the next frame's top rule. Crosses need no coordination acrossMain. - The outermost
Pageadds a script to the document head that restores the saved theme before first paint, soapp.htmlneeds no theme code. - Both width modes share responsive minimum margins:
--space-7, and--space-4on narrow viewports (--narrow). Larger screen safe areas increase both margins equally. - The viewport height is a minimum, not a cap: short content fills the viewport and longer content keeps its natural document scroll.
Footerdecorations do not add extra scroll below the frame. - Use style="min-height: 0" for an embedded preview that should not fill the viewport. Content padding belongs to the child sections.
- Available width comes from the parent; content padding belongs to child sections. Without
Main, the composition owns content growth. The internal page class is not a standalone foundation utility. - A direct
asideswitches the frame to a grid:HeaderandFooterspan its width, the aside takes a start column of 14 to 18rem and the remaining content element, usuallyMain, fills the rest and grows into the viewport height. Below--medium, the aside stacks between the header and the content; a sidebar that changes form on narrow screens switches at the same breakpoint. Without an aside,Pagestays a single column. - The aside draws its own rules, like any frame: top and start rules beside the content, whose start rule closes it, plus its end rule once stacked. It stretches over the content row, so a sticky child follows the scroll. Place one content element beside it; fixed children such as
SkipLinkandDialogtake no place in the layout.
05Parameters
| Name | Type | Default | Description |
|---|---|---|---|
lang | 'en' | 'fr' | undefined | Language of the page content and of every built-in label in the toolkit components it contains. Omitted, labels are English and the document language applies. |
width | string | "100rem" | Maximum frame width. Use full to remove the maximum; the frame still respects its margins. |
class | string | "" | Additional classes on the frame; existing classes are retained. |
children | Snippet | undefined | Page content, usually Header, Main and Footer, with an optional sidebar aside before Main. |
06Accessibility
Page is a layout container. Compose one Main landmark and place SkipLink as the first child of Page; its fixed position keeps it visible above the frame. Set lang to the audience language so built-in accessible names match it. Name a sidebar aside with aria-label; it precedes Main in reading and focus order, and SkipLink lets keyboard users bypass it.