Tally UI

NavDrawer

NavDrawer is the phone layout's slide-over navigation, closed by Escape, a backdrop press or a choice.

Import

import { NavDrawer } from '@tallyui/components';

Usage

const [open, setOpen] = useState(false);

<NavDrawer
  open={open}
  onOpenChange={setOpen}
  items={navItems}
  activeId="pos"
  onNavigate={(id) => router.navigate(`/${id}`)}
/>

AppShell renders it on phones and opens it from the RegisterBar menu, so most apps never use it directly. The 200 px panel slides in from the left over a dimmed backdrop. It is a modal dialog holding a navigation landmark. On the web, focus moves into the panel, Tab and Shift+Tab stay inside it, and focus returns to where it was when the drawer closes. Escape, a backdrop press or an item press closes it, and pressing the current item only closes it.

Props

PropTypeDefaultDescription
openbooleanrequiredWhether the drawer is shown
onOpenChange(open: boolean) => voidrequiredCalled with false when the drawer asks to close
itemsShellNavItem[]requiredNavigation entries
activeIdstring---The id of the item marked aria-current="page"
onNavigate(id: string) => voidrequiredCalled with the pressed item's id when it isn't the active one
headerReactNode---Drawn above the items, such as the store name
footerReactNode---Drawn at the foot of the panel, under the items, such as the app version
testIDstring'nav-drawer'Test identifier; the panel is <testID>-panel and the backdrop <testID>-backdrop

On this page