Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Drawer

Used to render a content that slides in from the side of the screen.

SourceStorybookRecipeArk

Usage

import { Drawer } from "@chakra-ui/react"
<Drawer.Root>
  <Drawer.Backdrop />
  <Drawer.Trigger />
  <Drawer.Positioner>
    <Drawer.Content>
      <Drawer.CloseTrigger />
      <Drawer.Header>
        <Drawer.Title />
      </Drawer.Header>
      <Drawer.Body />
      <Drawer.Footer />
    </Drawer.Content>
  </Drawer.Positioner>
</Drawer.Root>

Examples

Controlled

Use the open and onOpenChange props to control the drawer component.

Sizes

Use the size prop to change the size of the drawer component.

Context

Use the DrawerContext component to access the drawer state and methods from outside the drawer.

Offset

Pass the offset prop to the DrawerContent to change the offset of the drawer component.

Placement

Use the placement prop to change the placement of the drawer component.

Initial Focus

Use the initialFocusEl prop to set the initial focus of the drawer component.

Custom Container

Here's an example of how to render the drawer component in a custom container.

Consider setting closeOnInteractOutside to false to prevent the drawer from closing when interacting outside the drawer.

Render drawer here

Header Actions

Here's an example of rendering actions in the header of the drawer component.

Props

Root

PropDefaultType
colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'

The color palette of the component

size 'xs'
'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full'

The size of the component

placement 'end'
'start' | 'end' | 'top' | 'bottom'

The placement of the component

contained
'true' | 'false'

The contained of the component

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
unstyled
boolean

Whether to remove the component's style.

Previous

Dialog

Next

Editable