Skip to content
Mosaic
On this page

Drawer

A bottom sheet that rises from the bottom of the screen, with a scrim and a grip. Drag it down, press Escape or press outside to dismiss. Wraps the headless Drawer primitive.

Use for

  • a bottom sheet on a small screen
  • a draggable panel with snap points
  • a sheet opened from inside a card or profile dialog

Practices

GuidancePractice
DoName the sheet with Drawer.Title, and describe it with Drawer.Description.
DoPass autoFocus only when the sheet opens to a field the user types in at once. It is off so opening on touch does not raise the keyboard.

API reference

Drawer.Root

Holds the open state, dismissal, snap points and drag policy. Renders no element.

PropTypeDescription
openbooleanWhether the sheet is open, when controlled.
defaultOpenbooleanWhether the sheet is open on mount.
onOpenChange(open: boolean) => voidCalled when the sheet opens or closes.
modalbooleanTraps focus and blocks the rest of the page.Default: true
handleHeadlessDrawerProps['handle']Imperative handle for a trigger rendered outside Drawer.Root.
snapPointsnumber[]Ascending fractions (0 to 1) of the viewport the sheet rests at.
activeSnapPointnumberThe active snap point index, when controlled.
defaultActiveSnapPointnumberThe active snap point index on mount.Default: the last, most open
onActiveSnapPointChange(index: number) => voidCalled with the new snap point index.
dismissiblebooleanLets a downward release past the threshold, or an outside press, close it.Default: true
handleOnlybooleanStarts a drag only from the grip.Default: false
repositionInputsbooleanKeeps a focused field above the virtual keyboard.Default: true
autoFocusbooleanMoves focus into the sheet on open.Default: false

Drawer.Trigger

The headless trigger button that opens the sheet.

Drawer.Popup

The sheet, with its portal, viewport (cl-drawer-viewport), scrim (cl-drawer-backdrop, data-nested inside a dialog), grip (cl-drawer-handle, cl-drawer-grip) and content box (cl-drawer-content).

Slot: cl-drawer-popup

PropTypeDescription
finalFocusDrawerFocusTargetWhere focus returns when the sheet closes.Default: the trigger

Drawer.Title

The headless title the sheet is labelled by.

Drawer.Description

The headless description the sheet is described by.

Drawer.Close

The headless button that closes the sheet from inside.

Examples

A sheet

TSX
<Drawer.Root>
  <Drawer.Trigger>{m.open}</Drawer.Trigger>
  <Drawer.Popup>
    <Drawer.Title>{m.title}</Drawer.Title>
    <Drawer.Description>{m.description}</Drawer.Description>
    <Drawer.Close>{m.done}</Drawer.Close>
  </Drawer.Popup>
</Drawer.Root>