All components (283)
App shell
Structure · AppShell · .amset-shell
What it is and when to use it
The shell of an application: header, side column, content and footer, in a CSS grid and in a single component: header, sider, children and footer.
When to use it
- The frame of a management screen:
TopBaron top,SideNavon the left and the content in the middle.
collapsedfolds the column to icons only (it measurescollapsedWidth, 4.5 rem by default, and the change is animated); with a function insiderthe menu receives{ collapsed }to hand toSideNav.breakpoint('64rem') changes from which width the column goes over the content.landmarksturns the header, the column and the footer into a real<header>,<nav>(withsiderLabel) and<footer>, only if what is inside is not already a landmark.
When not to
- A public page or a landing page: there is no application column or header there.
What it gives without being asked: the content is a <main> with an id (mainId, content by default) and tabindex="-1" —the target of the TopBar "skip to content" link (skipTo)—, the header stays fixed (stickyHeader={false} to turn that off), and the side column stays fixed right below it (it measures its height) with its own scrolling if the menu is taller than the window.
Narrow screen (under 48 rem): the column moves above the content and stops being fixed, unless it is a SideNav: that one stays in its tile rail below 40 rem and remains next to the content, fixed and all the way down. A menu that hides behind a button needs its own panel (Drawer) and that is mounted outside.
Keyboard and accessibility: Tab goes through the header, the column and the content, in that order. With a TopBar that has skipTo, the first Tab offers "Skip to content".
Fine-tuning: --amset-shell-sider-width (16 rem; also with the siderWidth prop) and --amset-shell-gap (content padding).
What it looks like
orders
Order 1040
Awaiting shipment
Order 1041
Awaiting shipment
Order 1042
Awaiting shipment
Order 1043
Awaiting shipment
Order 1044
Awaiting shipment
Order 1045
Awaiting shipment
<AppShell
header={<TopBar brand="Aurelia Jewelry" skipTo="contenido" actions={<Avatar name="Lucia Ferrer" size="sm" />} />}
sider={
<SideNav
label="Main menu"
sections={secciones}
active={activo}
onNavigate={(clave) => setActivo(clave)}
collapsed={plegado}
onCollapsedChange={setPlegado}
/>
}
siderWidth="auto"
mainId="contenido"
>
<Pedidos />
</AppShell>Props
Import it with import { AppShell } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
childrenrequired | ReactNode | The content of the screen. |
breakpoint | string | From which window width the column goes over the content, as a CSS length (`'64rem'`, `'1024px'`). 48 rem by default. With another value it is measured with `matchMedia` on mount: until then the 48 rem one applies. |
className | string | Merged with the library classes; it does not replace them. |
collapsed | boolean | Folds the column to icons only on a wide screen: the column measures `collapsedWidth` and the change is animated. Whoever mounts the shell decides (a button, a saved preference); the menu inside receives it through the function form of `sider`. |
collapsedWidth | string | Width of the folded column. 4.5 rem by default. |
footer | ReactNode | The footer of the page, under the content. |
header | ReactNode | The top bar: normally a `TopBar`. It stays fixed when scrolling. |
landmarks | boolean | Header, column and footer as real page landmarks: `<header>`, `<nav>` and `<footer>` instead of `div`. Only for slots with loose content: if what is inside is already a `<header>`, a `<nav>` or a `SiteFooter`, that one is already the landmark and duplicating it gives two. No by default. |
mainId | string | The `id` of the main content. The "skip to content" link of the `TopBar` (`skipTo`) points to it. By default, `content`. |
sider | ReactNode | ((state: ShellSiderState) => ReactNode) | The left column: normally a `SideNav`. It stays fixed under the header. With a function it receives `{ collapsed }`, to hand it to the menu (`<SideNav collapsed={collapsed} />`). |
siderLabel | string | The name of the column as `<nav>` (with `landmarks`): “Main menu”. Without it, the reader says just “navigation”. |
siderWidth | string | Width of the left column. By default, that of `--amset-shell-sider-width` (16 rem). |
stickyHeader | boolean | The header stays stuck to the top when scrolling. Yes by default. |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
CSS variables
These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.
| Variable | Default |
|---|---|
--amset-shell-sider-width | 16rem |
--amset-shell-gap | var(--amset-space-6) |
How to change it
.amset-shell {
--amset-shell-sider-width: ...;
--amset-shell-gap: ...;
}In the test bench
Every state and variant, to try one at a time, on its page at storybook.amsetui.com:
