Drawer

A drawer is a content panel that slides in from the side of the screen. It is typically used to display additional content that relates to the page behind it.

A drawer with a heading that reads 'Choose services' sits on a dark transparent veil

How to use drawers

Drawers are used to provide contextual information that is relevant to the page content underneath it. They are useful for cross referencing but only intended for a specific action. As drawers are disruptive to the user's experience, they should be used sparingly.

Use a drawer:

  • Display additional or supplemental information to the user about an element or item.
  • Make simple, contextual tasks available, for example adding or editing items within forms that would create scrolling or other usability issues if presented inline or in a modal.

Don’t use a drawer:

  • If the additional content is part of a flow, consider loading a new page or grouping content into an accordion instead.
  • If you want the user to focus on only the content in the drawer, we recommend you use a modal for this.
  • When confirming an action, consider using a modal instead.

Anatomy of a drawer

A drawer can include the following:

  • Header: includes a title, supporting text, leading icon, and a dismiss icon button.
  • Content: contains the content and/or controls needed to complete the drawer’s task. It can include text and/or components.
  • Footer (optional): contains the primary actions needed to complete or cancel the drawer task. Blanket: a tinted transparent overlay that deprioritises the page content underneath the drawer.
A drawer separated into three to display the header, content and footer elements that make up the component

Behaviour of a drawer

Size

The drawer is available in four sizes: small (30%), medium (60%), large (90%), and full (100%). On smaller devices (<640px/sm breakpoint), the drawer becomes fluid and occupies 100% of the viewport.

Three examples of the drawer demonstrate the width of a drawer. On mobile, it takes up 100% while the tablet and desktop examples take up 90% of the viewport

Position

The drawer is able to slide into view from four different positions: top, left, bottom, and right.

Four examples of the drawer demonstrate the element sliding into view from the top, left, bottom and right

Dismiss

The drawer is dismissible by using the ‘X’ icon in the drawer header (a child component). Alternatively, the user can click on the blanket to close the drawer. For keyboard users, they will press Escape to close the drawer.

A drawer within a desktop viewport is being dismissed by pressing the cross icon in the top right, another cursor is pressing the blanket to indicate an alternative way of dismissing the drawer

Usage guidelines

Avoid overlapping drawers

Drawers are designed to be interruptive, ensuring that the users focus is only on the content within the drawer. Therefore, it's important that only one is used at a time and they are not stacked or nested.

Do
A single drawer is displayed with a dark transparent veil sitting behind it
Don't
A collection of drawers are displayed, overlapping one another with a dark transparent veil sitting behind them

Content guidelines

Headings

All drawers must have a descriptive heading that describes the content within the drawer.

Do
A drawer with a heading that reads 'Added to trolley' sits on a dark transparent veil
Don't
A drawer with a heading that reads 'More information' sits on a dark transparent veil

Actions

Actions are optional within a drawer, but when they’re used they should be easy to understand what will happen if the button is used.

Do
A drawer with two actions that read 'Go to trolley' and 'Continue shopping' sits on a dark transparent veil
Don't
A drawer with two actions that read 'Trolley' and 'Cancel' sits on a dark transparent veil

Accessibility

Aria

Use the aria-label or aria-labelledby prop to add an accessible name to the drawer. This will tell assistive technologies the name of the element given by this label helping users to understand what the element is for and how they can interact with it.

Focus Considerations

When a drawer opens, the drawer container receives focus. The objective of this is “focus trapping”, which allows the user to tab through drawer content without the risk of falling out of it’s tab index.

Keyboard Navigation

Keyboard navigation is important for helping users who do not use a mouse or pointer device. All interactive elements like links, buttons and controls must be able to receive focus and be operable using standard keyboard controls.

  • Tab: Moves focus to next focusable element inside the drawer. When focus is on the last focusable element in the drawer, moves focus to the first focusable element in the drawer.
  • Shift+Tab: Moves focus to previous focusable element inside the drawer. When focus is on the first focusable element in the drawer, moves focus to the last focusable element in the drawer.
  • Escape: Closes the drawer.

Get in touch

Our team can answer any questions about using drawers or give you a helping hand with your next project.

Was this page helpful?


Select a theme to demo: