---
title: "Drawer"
description: "A modal panel that slides against an edge of the screen and closes on Escape, overlay click or an explicit close control."
---

A panel against an edge of the screen, built on [Radix Dialog](https://www.radix-ui.com/primitives/docs/components/dialog) in React and [Reka UI Dialog](https://reka-ui.com/docs/components/dialog) in Vue. The primitive owns the behaviour; newt/ui owns the look.

Use it to show or edit the details of something while the page it came from stays in view: a member's profile from the member list, a filter panel, a settings form. When the content is short and needs a decision, use a [Modal](/docs/components/modal).

_Live example of Drawer — see the page for the rendered demo._

## Installation

```bash
npx newtui@latest add drawer
```

npm dependencies: React: radix-ui. Vue: reka-ui.

Files written — React: components/ui/drawer.tsx. Vue: components/ui/drawer/Drawer.vue, components/ui/drawer/DrawerTrigger.vue, components/ui/drawer/DrawerContent.vue, components/ui/drawer/DrawerHeader.vue, components/ui/drawer/DrawerTitle.vue, components/ui/drawer/DrawerDescription.vue, components/ui/drawer/DrawerBody.vue, components/ui/drawer/DrawerFooter.vue, components/ui/drawer/DrawerClose.vue, components/ui/drawer/index.ts.

## Usage

React:

```tsx
import { Drawer } from "@/components/ui/drawer"
```

Vue:

```ts
import { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerBody, DrawerFooter, DrawerClose } from "@/components/ui/drawer"
```

Put `DrawerTrigger` and `DrawerContent` inside `Drawer`. `DrawerContent` holds a `DrawerHeader` with a `DrawerTitle`, then a `DrawerBody`, then an optional `DrawerFooter`. `DrawerBody` scrolls when the content is taller than the screen. The header and the footer stay in place.

## API reference

**`Drawer`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open / v-model:open` | `boolean` | — | Whether the drawer is shown. Leave it out and pass `defaultOpen` to let the drawer own it. |
| `onOpenChange` | `(open: boolean) => void` | — | React only. Called when the drawer asks to open or close; Vue emits `update:open`. |

**`DrawerContent`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `side` | `"end" \| "start" \| "bottom"` | `"end"` | The edge it sits against. `end` is the right in left-to-right text and the left in right-to-left. |
| `onCloseAutoFocus` | `(event: Event) => void` | — | Called when focus is about to return to the trigger. Call `event.preventDefault()` and focus an element yourself when the drawer opened without a `DrawerTrigger`. Vue emits `close-auto-focus`. |
| `aria-describedby` | `string \| undefined` | — | Pass `undefined` when the drawer has no `DrawerDescription`. |
| `container` | `HTMLElement` | `document.body` | Element the overlay and panel are portalled into. A drawer below a `DirectionProvider` or a themed wrapper passes that element to keep the direction and the palette. |

**`DrawerHeader`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `closeLabel` | `string` | `"Close"` | Accessible name of the close button in the header. |

`DrawerTrigger` and `DrawerClose` render a button. Pass `asChild` (`as-child` in Vue) to put the behaviour on your own element, such as a `Button`. `DrawerTitle` and `DrawerDescription` go inside `DrawerHeader`. Every part also accepts the native attributes of the element it renders, and a `className` that is merged rather than replaced.

## Accessibility

The panel carries `role="dialog"` and `aria-modal="true"`, and closes on `Escape` or a press on the dimmed page. `DrawerTitle` is its accessible name, so always render one with real text. `DrawerDescription` is its accessible description. When the drawer opens, focus moves to its first control. While it is open, Tab and Shift+Tab stay inside the panel, and the primitive hides the page behind from screen readers. When it closes, focus goes back to the `DrawerTrigger`. The close button in the header has a visible focus ring and takes its name from `closeLabel`. Use `side="bottom"` on a phone, where a side panel would cover the whole screen.

`closeLabel` on `DrawerHeader` names the close button; it defaults to `Close`. [Translating labels](/docs/translating-labels) lists every English default.

## Tokens

Drawer reads its colours, radii and motion from the `--newt-*` tokens. Override a token rather than editing the component.
