MobileNavSheet
The phone nav (<860px): a modal sheet from the inline-start edge with the whole nav, the brand, an optional card and a footer. Focus moves to the close button and is held inside (Tab wraps); Escape, the backdrop and picking an item close it, and focus returns to the button that opened it. The body does not scroll and the page behind is inert. It slides in and, when open turns false, slides back out (CSS, 200ms) before it unmounts; focus goes back to the opener and the page stops being inert once the slide has ended. Under prefers-reduced-motion (or with no animation in the stylesheet) it unmounts at once.
import { MobileNavSheet } from '@ergasti/bricks';Examples
Phone navigation sheet
A bottom sheet with every destination; focus is trapped, Escape and the scrim close it.
Code
import { useState } from 'react';
import { Button, MobileNavSheet } from '@ergasti/bricks';
import { brandMark, brandNav } from './nav';
function Sheet() {
const [open, setOpen] = useState(false);
const [active, setActive] = useState('home');
return (
<>
<Button variant="ink" onClick={() => setOpen(true)}>Open the sheet</Button>
<MobileNavSheet open={open} onClose={() => setOpen(false)} brand={brandMark} groups={brandNav} activeId={active} onSelect={(item) => { setActive(item.id); setOpen(false); }} footer={<Button>Sign out</Button>} />
</>
);
}With the sidebar's card
card draws under the nav and before the footer, so what the desktop sidebar shows under its nav (a help card, the PR portal's Open decisions) stays reachable on a phone. Inside an AppShell you do not pass it: the shell hands its sidebarCard and sidebarFooter to the sheet unless you set sheetFooter.
Code
import { useState } from 'react';
import { Button, MobileNavSheet, SidebarCard } from '@ergasti/bricks';
import { brandMark, brandNav } from './nav';
function WithCard() {
const [open, setOpen] = useState(false);
return (
<>
<Button variant="ink" onClick={() => setOpen(true)}>Open the sheet</Button>
<MobileNavSheet open={open} onClose={() => setOpen(false)} brand={brandMark} groups={brandNav} activeId="home"
card={<SidebarCard title="Need a hand?" action={<Button size="sm">Contact TRNDR</Button>}>Your account manager answers within a day.</SidebarCard>}
footer={<Button>Sign out</Button>} />
</>
);
}Props
Prop
Type
Design guidance
How the BRICKS design system uses MobileNavSheet. Written in docs/content/components/MobileNavSheet.md; the props above are read from the code, which wins where the two disagree.
The phone navigation sheet (under 860px): a modal panel sliding in from the start edge with the brand, the whole nav and a footer (contact, sign out); AppShell opens it from the header's menu button or the tab bar's More.
The library adds it for the phone tier (the mocks are desktop). Focus moves to its close button and stays inside (Tab wraps); Escape, the backdrop, × and picking an item close it, and focus returns to the button that opened it. The page behind is inert and does not scroll. It slides in and out in 200ms (CSS) and unmounts at once under reduced motion.
Anatomy
- Dialog (
.kit-shell-sheet,role="dialog",aria-modal, "Navigation sheet"). - Backdrop: 35% ink, fades in.
- Panel (
.kit-shell-sheet-panel): 84% wide, max 300px, dark sidebar colours, 22px × 14px padding. - Head: brand mark, the brand's
label, and a 44px × close button at the end. - Nav:
NavGroups(full labels, counts and badges). - Footer (
.kit-shell-sheet-foot, optional): above a thin rule; aLogoutButtonhere is drawn as an outlined white button.
Variants
None; it follows the NavGroups data. footer is optional.
States
| State | How |
|---|---|
| Closed | open={false}: nothing rendered (after the slide-out). |
| Open | open: focus on ×, page behind inert. |
| Closing | open turns false: slide-out plays; clicks ignored; focus returns after. |
| Reduced motion | Unmounts immediately. |
Usage
// Usually via AppShell: pass the footer
<AppShell brand={brand} nav={nav} activeId={route} onNavigate={go}
sheetFooter={<>
<Button size="sm" variant="lime">Contact TRNDR</Button>
<LogoutButton url="/logout" csrfToken={csrf}>Sign out</LogoutButton>
</>}>
…
</AppShell>// Directly, in a custom frame
const [open, setOpen] = useState(false);
<Button onClick={() => setOpen(true)}>Menu</Button>
<MobileNavSheet open={open} onClose={() => setOpen(false)} brand={brand} groups={nav} activeId="home" onSelect={go} lockRef={pageRef} />Where it appears
- Brand dashboard and PR Portal on phones (< 860px), from the header menu button or the tab bar's More.
AppShellstoryPhone.
Guidelines
Do
- Put sign out and the contact action in
footer. - Pass
lockRefwhen using it outsideAppShell.
Don't
- Don't open it on desktop; the sidebar is there.
- Don't add content other than navigation.
RTL and Arabic
- Slides in from the right in Arabic (mirrored keyframes); × sits on the left.
Tokens
--shell-side-bg, --shell-side-ink, --shell-nav-hover, --focus-ring-inverse; backdrop rgba(20,20,20,.35).
Accessibility
- Modal dialog with focus trap, Escape and focus return; the page behind is inert and
aria-hidden. - × is a 44px button named "Close"; the backdrop is
aria-hidden. - Respects
prefers-reduced-motion.
Found in the source
- Roles in the markup:
dialog. - ARIA attributes set:
aria-modal,aria-label,aria-hidden. - It traps focus while open and returns it on close.
- It locks the page behind it (inert, no scroll) while open.
- It honours reduced motion.
- Its tests cover: “is a labelled modal with the brand, the nav and More; picking an item reports it and closes”; “closes on Escape, the backdrop and the close button”; “keeps focus inside (Tab wraps) and returns it to the opener on close”; “puts the close button first in the focus order (focus lands there when the sheet opens in a browser)”; “slides out before it unmounts; focus and the page come back when the slide ends”; “under prefers-reduced-motion it unmounts at once and hands focus back”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
BottomNav: the More tab that opens it.AppHeader: the phone menu button.Drawer: a general side panel for content.
See also: useFocusTrap · useModalLock · useReducedMotion · NavGroups · useLanguage · Button · SidebarCard · AppShell · BrandMark
Source
src/shell/MobileNavSheet.tsx (line 50) on GitHub.