logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Drawer

Navigation drawers, or sidebars, offer user-friendly access to various sections of a website or app features, such as account switching.

A navigation drawer can be permanently visible or toggled via a navigation menu icon.
Side sheets are additional surfaces mainly utilized on tablets and desktops.

Temporary drawer

Temporary navigation drawers can be opened or closed. By default, they are closed and temporarily appear above all other content until a selection is made.
The Drawer can be dismissed by clicking the overlay or pressing the Esc key. It closes upon item selection, managed through the open prop.

Anchor

The anchor prop determines which side of the screen the Drawer emerges from.
The default anchor is set to left.

Swipeable

The SwipeableDrawer component enables swipe gestures to open or close the drawer.
This component adds a 2 kB gzipped payload. Some lower-end mobile devices may struggle to track finger movements at 60 FPS. The disableBackdropTransition prop can mitigate this issue.
The following settings are applied on this documentation site to optimize component usability:
  • iOS devices are typically high-end, allowing the backdrop transition to run smoothly without frame drops, ensuring adequate performance.
  • iOS includes a "swipe to go back" feature that conflicts with the discovery feature, requiring discovery to be disabled.
const iOS =
  typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent);

<SwipeableDrawer disableBackdropTransition={!iOS} disableDiscovery={iOS} />;

Swipeable edge

The SwipeableDrawer can be configured to display a visible edge when in the closed state.
On desktop, you can toggle the drawer using the "OPEN" button. On mobile, you can access the demo in CodeSandbox (via the "edit" icon) and swipe to open.

Keep mounted

The Modal used within the Swipeable Drawer has the keepMounted prop enabled by default, ensuring the drawer's contents remain in the DOM at all times.
You can modify this behavior using the ModalProps prop, though setting keepMounted: false may cause issues in React 18.
<Drawer
  variant="temporary"
  ModalProps={{
    keepMounted: false,
  
/>

Responsive drawer

The temporary variant can be used for small screens, while the permanent variant is suitable for wider screens.

Persistent drawer

Persistent navigation drawers can be toggled to open or close. Positioned at the same elevation as the content, they are closed by default and open when the menu icon is selected, remaining open until the user closes them. The drawer's state persists across actions and sessions.
When opened outside the page grid, the drawer causes other content to resize and adapt to the reduced viewport space.
Persistent navigation drawers are suitable for all screen sizes larger than mobile. They are not advised for applications with multiple hierarchy levels requiring an up arrow for navigation.

Mini variant drawer

In this variant, the persistent navigation drawer adjusts its width. In its resting state, it appears as a compact mini-drawer at the same elevation as the content, clipped by the app bar. When expanded, it functions as a standard persistent navigation drawer.
The mini variant is ideal for app sections requiring quick access to selections alongside content.

Permanent drawer

Permanent navigation drawers remain visible and fixed to the left edge at the same elevation as the content or background, without the option to close them.
Permanent navigation drawers are the recommended default for desktop applications.

Full-height navigation

Applications centered on information consumption with a left-to-right navigational hierarchy.

Clipped under the app bar

Applications focused on productivity that require balanced screen space distribution.