Drawer
Drawer displays content related to a minor job within a page’s main job that doesn’t demand complete attention. It does not block interactions outside the overlay, allowing users to interact with content.
Anatomy
The Drawer is a composition of several components:
Component | Description |
---|---|
DrawerProvider | Provides the state to all Drawer components |
DrawerTrigger | A composition-first component that toggles the DrawerPopover |
DrawerPopover | Popover box of the Drawer |
DrawerHeader | The fixed Header |
DrawerHeading | The title of the Drawer |
DrawerDismiss | Dismisses the DrawerPopover |
DrawerContent | Main content inside of the DrawerPopover |
DrawerFooter | The fixed Footer mainly used for actions |
The example code below, illustrates how these components interact with each other:
function Anatomy() {
return (
<DrawerProvider>
<DrawerTrigger asChild>
<Button>Open</Button>
</DrawerTrigger>
<DrawerPopover>
<DrawerHeader>
<DrawerHeading>Drawer Heading</DrawerHeading>
<DrawerDismiss />
</DrawerHeader>
<DrawerContent>
Content goes here
</DrawerContent>
<DrawerFooter>
<Button size="large">
Label
</Button>
<Button variant="primary" size="large">
Label
</Button>
</DrawerFooter>
</DrawerPopover>
</DrawerProvider>
)
}
Examples
Controlled
The open
and onChangeOpen
props of DrawerProvider are used to control the DrawerPopover open state.
Long content
The DrawerContent adds a scrollbar for long content.
Small size
The DrawerPopover has either a small
or medium
(default) size.
Related components
Modal
Modal displays content related to a minor job within a page's main job. It demands complete attention and blocks interactions outside the overlay.
Page
The Page structure helps users to easily identify where they are, view content essential to the main job, and perform related actions.
ContextualHelp
Contextual Help is represented by a question mark trigger that is positioned next to an element and displays its definition when clicked.