Drawer

Drawer lets you create accessible drawers that slide in and out 🙃.


This makes Drawers really easy to use

You just have to specify an id for the Drawer to get started.

<DrawerTrigger target="drawer"> ... </DrawerTrigger>
<DrawerContent id="drawer"> ... </DrawerContent>

Use a custom layout for your close button

We don’t force you into a predefined layout in your drawer content so you can put your custom close button anywhere you desire.

<DrawerContent id="drawer">
<div class="flex items-center gap-4">
<div>Drawer Content</div>
<DrawerCloseButton />
</div>
</DrawerContent>

Drawers that can show up from any side

Drawers can be placed on the top, bottom, left, and right of the screen. Just add placement to DrawerContent to change its placement.

<DrawerContent
id="drawer"
options={{placement: 'top'}}
>
...
</DrawerContent>

Ultra versatile, since Drawers can be placed in various positions

You can use static, absolute, and fixed to adjust how drawers show up.

  • static is good for disclosure
  • absolute is great for megamenus
  • fixed is awesome for sitewide navigation
<DrawerContent
id="drawer"
options={{position: 'static'}}
>
...
</DrawerContent>

Actually accessible (not just claiming to be)

Drawer designed to be as accessible as possible from the get-go. Allow us to explain what these features are.

First — the most basic — you can close the drawer by clicking outside or with the Esc button)

Try it by opening the drawer and press the Esc button!

Impeccable focus management

Unlike many other drawer components, Drawer helps you focus on the right thing at the right time.

  • When opening: Focus is placed on DrawerContentso keyboard users and screen readers can start interacting with it immediately.
  • When closing: Focus is placed on DrawerTrigger so keyboard and screen reader users navigate to the next item without using a mouse.
  • Inside DrawerContent: Focus is handled differently depending on its position. For more details, see the accessibility tab.

Get a feel of how we handle focus by tabbing through these drawers

The right roles and the right labels

Drawers are usually dialogs so we built them with an implict dialog role. (This can be changed if you wish to).

And since dialogs need accessible names, we also built-in an accessibility warning and wrote a section to help you understand how to create these names.

An accessibility warning
Warning about missing accessible name for a drawer.

As you can see, we are pretty serious about accessibility!