Nav Drawer
Put your app's navigation in a panel that slides in from the side of the screen, opened from a menu button.
Installation
This also adds Icon, which draws the menu button's icon.
Usage
<ui-nav-drawer-trigger>is a menu button with a hamburger icon. It only emitspressed, so set youropensignal there.- The drawer covers 80% of the screen width and the full height, over a dimmed backdrop. A backdrop tap closes it.
- Tapping an item emits its
pressed, then closes the drawer. [active]highlights the item for the current page. When the drawer opens, it scrolls the active item into view.- An item lays out its content in a row. Put an icon and a
<text>in it. - The drawer draws in an
<overlay>, so it covers the whole screen wherever it sits in your template.
Layout
The drawer stacks up to three sections, each optional:
<ui-nav-drawer-header>at the top, padded clear of the status bar and notch.<ui-nav-drawer-content>in the middle. It fills the space left over and scrolls when the items don't fit.<ui-nav-drawer-footer>at the bottom, padded clear of the home indicator. Use it for account actions such as Log out.
Navigate with the router
pressed fires inside the tap. Changing signals there is safe, but router navigation isn't: wrap it in setTimeout. See the setTimeout rule for why.
Open from the right
Keep the drawer open
Set autoClose to false on an item that shouldn't close the drawer, such as one that expands a group.
API
UiNavDrawer
UiNavDrawerItem
UiNavDrawerTrigger
All sub-components (UiNavDrawerHeader, UiNavDrawerContent, UiNavDrawerItem, UiNavDrawerFooter, UiNavDrawerTrigger) accept class. Items only work inside a <ui-nav-drawer>, because they close it.
Related
- Routing and navigation: move between pages with the router
- Dialogs and overlays: how overlays work and which one to use
- Safe area: the insets the header and footer pad for
- Icon: icons for the items
