Navigation drawers provide access to destinations and app functionality, such as switching accounts. It can either be permanently on-screen or controlled by a navigation menu icon. A navigation drawer is recommended for: 1. Apps with five or more top-level destinations 2. Apps with two or more levels of navigation hierarchy 3. Quick navigation between unrelated destinations
See live demos on storybook
Storybook Drawer Demos
Install bundle from npm-e
npm i @element-public/react-components @element-public/themes
Optional: install the component individually
npm i @element-public/react-drawer @element-public/themes
Please Note: You will need to add @element-public to your .npmrc!
Open ~/.npmrc
in an editor and add the following line to enable the @element-public
scope:
@element-public:registry=https://npm.platforms.engineering
See below if you have never installed a package from Bayer's npm-enterprise or
run into the following error:
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR! npm login
See the
devtools npm-e guide
to learn how to create an access token if this is the first time you are using a
npm-e package at Bayer or you do not have a line that starts with the following
in your ~/.npmrc
file:
//npm.platforms.engineering/:_authToken=
The Drawer component works with, or include, other components, like Button, to open, close, and navigate the Drawer, Typography, to apply certain styles and sizes of text in the Drawer, and List, to improve the flow of the Drawer's contents for users.
Different Drawers should be used in various cases. For example, a Permanent Drawer could be used to prevent a user from closing or navigating away from the Drawer, so it is always visible. Alternatively, a Dismissible Drawer can be opened and closed by clicking a button, so it only appears when the user wants it to.
Drawer uses the following sub components:
Name |
Description |
Drawer |
Primary container for all the drawer contents |
DrawerHeader |
Contains the top title portion of the drawer. |
DrawerContent |
The container for the main body of the drawer. |
DrawerScrim |
Covers the screen behind the drawer component to focus the users attention. |
DrawerAppContent |
Container for app contents. Its child is resized when the drawer opens/closes. |
Name |
Type |
Default |
Required |
Description |
belowTopAppBar |
boolean |
null |
false |
Positions the modal lower, below the TopAppBar. |
className |
string |
undefined |
false |
The css class name to be passed through to the component markup. |
open |
boolean |
null |
false |
Displays the drawer when variant is either dismissible or modal` |
variant |
string |
empty string |
false |
Defines the type of drawer. By default the drawer will be always shown, a permanent drawer. If defined, either modal or dismissible Accepted Values: modal, dismissible |
Name |
Type |
Default |
Required |
Deprecated |
Description |
dismissible |
boolean |
undefined |
false |
Use variant='dismissible' instead. |
Enables a dismissible drawer. |
modal |
boolean |
undefined |
false |
Use variant='modal' instead. |
Enabled a modal drawer. |
Name |
Type |
Default |
Required |
Description |
children |
React.ReactNode |
null |
false |
Content to be rendered inside the Drawer |
Name |
Default |
Required |
Params |
Description |
onClose |
null |
false |
|
Fired when drawer is closed. |
onOpen |
null |
false |
|
Fired when drawer is opened. |
Description |
Drawer: Child component DrawerToolbarSpacer has been removed. See DrawerAppContent . |
Name |
Type |
Default |
Required |
Description |
belowTopAppBar |
boolean |
null |
false |
Positions the modal lower, below the TopAppBar. |
className |
string |
undefined |
false |
The css class name to be passed through to the component markup. |
Drawer App Content Render Props
Name |
Type |
Default |
Required |
Description |
children |
React.ReactNode |
null |
false |
Content to be rendered inside the DrawerAppContent |
Name |
Type |
Default |
Required |
Description |
className |
string |
undefined |
false |
The css class name to be passed through to the component markup. |
Drawer Content Render Props
Name |
Type |
Default |
Required |
Description |
children |
React.ReactNode |
null |
false |
Content to be rendered inside the drawer. Most commonly a list, but accepts any valid markup. |
Drawer Header Props
Name |
Type |
Default |
Required |
Description |
className |
string |
undefined |
false |
The css class name to be passed through to the component markup. |
subtitle |
string |
empty string |
false |
Subtitle of Drawer Header |
title |
string |
empty string |
false |
Title of Drawer Header |
Drawer Header Render Props
Name |
Type |
Default |
Required |
Description |
avatar |
React.ReactNode |
null |
false |
Most commonly an avatar style image, but accepts any valid markup. |
children |
React.ReactNode |
null |
false |
Most commonly a text or a Typography component, but accepts any valid markup. |