Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Overlays

Drawer

Free19.0 KB gzipped

A panel that slides in from an edge of the screen: navigation, filters, details, or a mobile bottom sheet. Follows the WAI-ARIA APG modal dialog pattern (or a non-modal dialog with modal={false}).

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Enter, Space, Escape and 2 more · Full report

Import

tsx
import { Drawer } from "@vjdesigns/vjdesigns-ui";

Importing only Drawer adds about 19.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Filters

A modal panel from the edge of the screen. Focus moves inside, the page behind is inert, and Escape closes it.

tsx
import { CheckBox, Drawer, Stack } from "@vjdesigns/vjdesigns-ui";

export function Filters() {
  return (
    <Drawer>
      <Drawer.Trigger variant="outline" tone="neutral">
        Filters
      </Drawer.Trigger>
      <Drawer.Content>
        <Drawer.Header>
          <Drawer.Title>Filters</Drawer.Title>
          <Drawer.Description>Narrow down the product list.</Drawer.Description>
        </Drawer.Header>
        <Drawer.Body>
          <Stack gap={4}>
            <CheckBox label="In stock" defaultChecked />
            <CheckBox label="On sale" />
            <CheckBox label="Free shipping" />
          </Stack>
        </Drawer.Body>
        <Drawer.Footer>
          <Drawer.Close variant="ghost" tone="neutral">
            Reset
          </Drawer.Close>
          <Drawer.Close>Show results</Drawer.Close>
        </Drawer.Footer>
      </Drawer.Content>
    </Drawer>
  );
}

Bottom sheet

side="bottom" makes a bottom sheet, which suits phones. It can be swiped down to close.

Closed

tsx
import { useState } from "react";
import { Button, Drawer, Flex, Text } from "@vjdesigns/vjdesigns-ui";

export function BottomSheet() {
  const [open, setOpen] = useState(false);
  return (
    <Flex gap={3} align="center">
      <Drawer open={open} onOpenChange={setOpen} side="bottom" size="sm">
        <Drawer.Trigger>Share</Drawer.Trigger>
        <Drawer.Content>
          <Drawer.Header>
            <Drawer.Title>Share this page</Drawer.Title>
          </Drawer.Header>
          <Drawer.Body>
            <Flex gap={3} wrap="wrap">
              <Button variant="soft" onClick={() => setOpen(false)}>
                Copy link
              </Button>
              <Button variant="soft" onClick={() => setOpen(false)}>
                Email
              </Button>
              <Button variant="soft" onClick={() => setOpen(false)}>
                Message
              </Button>
            </Flex>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>
      <Text size="sm" tone="muted">
        {open ? "Open" : "Closed"}
      </Text>
    </Flex>
  );
}

Accessibility

A drawer is a modal dialog: it's named by Drawer.Title, traps focus while open, closes with Escape or its named close button, and returns focus to the trigger. side="start" and "end" are logical, so they flip in right-to-left layouts.

tsx
import { CheckBox, Drawer, Stack, Text } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Drawer side="end">
      <Drawer.Trigger variant="outline" tone="neutral">
        Notification settings
      </Drawer.Trigger>
      <Drawer.Content>
        <Drawer.Header>
          <Drawer.Title>Notification settings</Drawer.Title>
          <Drawer.Description>Choose how we contact you.</Drawer.Description>
        </Drawer.Header>
        <Drawer.Body>
          <Stack gap={3}>
            <CheckBox label="Email" defaultChecked />
            <CheckBox label="Text message" />
          </Stack>
        </Drawer.Body>
        <Drawer.Footer>
          <Drawer.Close>Done</Drawer.Close>
        </Drawer.Footer>
      </Drawer.Content>
    </Drawer>
  );
}

Translated

In Arabic, side="end" opens the drawer from the left edge, and the close button's name comes from the locale.

tsx
import {
  CheckBox,
  Drawer,
  Stack,
  LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function Translated() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <Drawer side="end">
        <Drawer.Trigger variant="outline" tone="neutral">
          عوامل التصفية
        </Drawer.Trigger>
        <Drawer.Content>
          <Drawer.Header>
            <Drawer.Title>عوامل التصفية</Drawer.Title>
          </Drawer.Header>
          <Drawer.Body>
            <Stack gap={3}>
              <CheckBox label="متوفر في المخزون" defaultChecked />
              <CheckBox label="شحن مجاني" />
            </Stack>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>
    </LocaleProvider>
  );
}

Usage notes

tsx
<Drawer>
  <Drawer.Trigger>Filters</Drawer.Trigger>
  <Drawer.Content>
    <Drawer.Header>
      <Drawer.Title>Filters</Drawer.Title>
    </Drawer.Header>
    <Drawer.Body>...</Drawer.Body>
    <Drawer.Footer>
      <Drawer.Close>Cancel</Drawer.Close>
    </Drawer.Footer>
  </Drawer.Content>
</Drawer>

API reference

Drawer

Drawer props
PropTypeDefault
children

Drawer.Trigger and Drawer.Content, plus anything else that should read the drawer's state.

ReactNode—
open

Controlled open state.

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state whenever the drawer opens or closes.

(open: boolean) => void—
side

Edge the drawer slides in from. start and end are logical: in a right-to-left layout end is the left edge. bottom is a mobile-style bottom sheet with a grab handle.

"start""end""top""bottom""end"
size

Width (start/end) or height (top/bottom). Presets: sm 20rem, md 30rem, lg 40rem wide (or 33%, 50%, 75% of the viewport tall), and full. Pass a CSS length ("28rem") or a number of px for a custom size. Never wider than the viewport minus a gutter, except full.

DrawerSize"md"
modal

true (default): a modal dialog. A backdrop covers the page, the page is inert and can't scroll, and focus is trapped in the drawer.

false: a non-modal dialog (a side panel). No backdrop, no focus trap, the page stays interactive and scrollable. Focus moves into the panel when it opens; Escape closes it only while focus is inside it. Pass role="complementary" on Drawer.Content instead if the panel is persistent supporting content rather than a task.

booleantrue
closeOnOverlayPress

Close when the backdrop is pressed (modal drawers only).

booleantrue
closeOnEscape

Close on Escape. Only the topmost open drawer responds.

booleantrue
swipeToClose

Bottom sheets only: let users swipe the grab handle down to close. It's a shortcut; the Close button stays, so dragging is never required.

booleantrue
initialFocusRef

Element to focus when the drawer opens. Defaults to the first focusable element (usually the close button).

RefObject<HTMLElement | null>—
finalFocusRef

Element to focus when the drawer closes. Defaults to Drawer.Trigger, or whatever was focused when it opened.

RefObject<HTMLElement | null>—

Drawer.Trigger

Drawer.Trigger props
PropTypeDefault
children

The visible label.

ReactNode—
startIcon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the label. Hidden from assistive technology.

ReactNode—
loading

Shows an inline spinner, sets aria-busy, and ignores clicks. The button keeps its width and stays focusable.

booleanfalse
loadingText

Label shown (and announced) next to the spinner while loading. Defaults to keeping the normal label as the accessible name.

ReactNode—
loadingLabel

Announced to screen readers when loading starts (a plain string loadingText is announced instead). Localize it here.

string"Loading"
fullWidth

Stretches the button to fill its container. Inherits from a surrounding ButtonGroup.

booleanfalse
compact

Tighter side padding, so a short label (a page number, "OK") makes a button no wider than it is tall.

booleanfalse
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
href

Pass a URL to render the control as a link (<a>).

undefined—
asChild

Clone the single child element instead of wrapping children in a Button. Use it for an icon-only trigger: <Drawer.Trigger asChild><IconButton aria-label="Menu">...</IconButton></Drawer.Trigger>. The child must be a button that accepts ref, onClick, and aria-*.

booleanfalse

Also accepts standard HTML attributes, plus className, style and ref.

Drawer.Content

Drawer.Content props
PropTypeDefault
children

Header, body, and footer parts.

ReactNode—
hideCloseButton

Hide the built-in close button in the top corner. Only do this if the drawer has another visible Drawer.Close.

booleanfalse
closeLabel

Accessible name of the built-in close button.

string"Close"
overlayClassName

Extra class for the backdrop (modal drawers only).

string—
container

Element to portal into.

HTMLElement | nulldocument.body

Also accepts native <div> attributes, plus className, style and ref.

Drawer.Header

Drawer.Header props
PropTypeDefault
children

Usually a Drawer.Title, optionally followed by a Drawer.Description.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Drawer.Title

Drawer.Title props
PropTypeDefault
as

Heading level to render. Pick the one that fits the page outline.

"h1""h2""h3""h4""h5""h6""h2"
childrenRequired

The drawer's name. Announced when the drawer opens (it labels the dialog).

ReactNode—

Also accepts native <h2> attributes, plus className, style and ref.

Drawer.Description

Drawer.Description props
PropTypeDefault
children

Supporting text. The dialog is aria-describedby it. Keep it short.

ReactNode—

Also accepts native <p> attributes, plus className, style and ref.

Drawer.Body

Drawer.Body props
PropTypeDefault
children

The main content. Scrolls when it's taller than the drawer.

ReactNode—
flush

Drop the body's padding so content (an image, a map, a nav list with its own spacing) runs edge to edge. The body still scrolls.

booleanfalse

Also accepts native <div> attributes, plus className, style and ref.

Drawer.Footer props
PropTypeDefault
children

Actions (e.g. "Apply" and "Reset"). Stays visible while the body scrolls.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

Drawer.Close

Drawer.Close props
PropTypeDefault
children

The visible label.

ReactNode—
startIcon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the label. Hidden from assistive technology.

ReactNode—
loading

Shows an inline spinner, sets aria-busy, and ignores clicks. The button keeps its width and stays focusable.

booleanfalse
loadingText

Label shown (and announced) next to the spinner while loading. Defaults to keeping the normal label as the accessible name.

ReactNode—
loadingLabel

Announced to screen readers when loading starts (a plain string loadingText is announced instead). Localize it here.

string"Loading"
fullWidth

Stretches the button to fill its container. Inherits from a surrounding ButtonGroup.

booleanfalse
compact

Tighter side padding, so a short label (a page number, "OK") makes a button no wider than it is tall.

booleanfalse
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
href

Pass a URL to render the control as a link (<a>).

undefined—

Also accepts standard HTML attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Drawer targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
EnterSpaceOn the trigger: opens the drawer.
EscapeCloses the drawer (non-modal: only while focus is inside it).
TabShift+TabMoves through the focusable elements inside, wrapping at the ends (focus stays inside).

Modal (default): focus moves in on open, is trapped, the page is inert, and focus returns to the trigger on close. Non-modal: no trap; the page stays interactive.

Roles and states

Roles and states
ElementRoleStates and properties
Drawer.Contentdialogaria-modal when modal, aria-labelledby → title, aria-describedby → description
Triggerbuttonaria-haspopup="dialog", aria-expanded, aria-controls
Close buttonbuttonaria-label

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)