Skip to content
EspañolEnglish
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: TopBar on top, SideNav on the left and the content in the middle.
  • collapsed folds the column to icons only (it measures collapsedWidth, 4.5 rem by default, and the change is animated); with a function in sider the menu receives { collapsed } to hand to SideNav. breakpoint ('64rem') changes from which width the column goes over the content. landmarks turns the header, the column and the footer into a real <header>, <nav> (with siderLabel) 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

Skip to content
Aurelia Jewelry

orders

Order 1040

Awaiting shipment

Two rings and a pendant.

Order 1041

Awaiting shipment

Two rings and a pendant.

Order 1042

Awaiting shipment

Two rings and a pendant.

Order 1043

Awaiting shipment

Two rings and a pendant.

Order 1044

Awaiting shipment

Two rings and a pendant.

Order 1045

Awaiting shipment

Two rings and a pendant.

<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.

PropTypeWhat it does
childrenrequiredReactNodeThe content of the screen.
breakpointstringFrom 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.
classNamestringMerged with the library classes; it does not replace them.
collapsedbooleanFolds 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`.
collapsedWidthstringWidth of the folded column. 4.5 rem by default.
footerReactNodeThe footer of the page, under the content.
headerReactNodeThe top bar: normally a `TopBar`. It stays fixed when scrolling.
landmarksbooleanHeader, 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.
mainIdstringThe `id` of the main content. The "skip to content" link of the `TopBar` (`skipTo`) points to it. By default, `content`.
siderReactNode | ((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} />`).
siderLabelstringThe name of the column as `<nav>` (with `landmarks`): “Main menu”. Without it, the reader says just “navigation”.
siderWidthstringWidth of the left column. By default, that of `--amset-shell-sider-width` (16 rem).
stickyHeaderbooleanThe 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.

VariableDefault
--amset-shell-sider-width16rem
--amset-shell-gapvar(--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: