Drawer

Drawer displays content related to a minor job within a page’s main job. It does not block interactions outside the overlay, allowing users to interact with content.

Anatomy

Drawer anatomy

The Drawer is a composition of several components:

ComponentDescription
DrawerProviderProvides the state to all Drawer components
DrawerTriggerA composition-first component that toggles the DrawerPopover
DrawerPopoverPopover box of the Drawer
DrawerHeaderThe fixed Header
DrawerHeadingThe title of the Drawer
DrawerDismissDismisses the DrawerPopover
DrawerContentMain content inside of the DrawerPopover
DrawerFooterThe 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.