Overlays
Drawer
Free19.0 KB gzippedA 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
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.
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
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.
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.
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
<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
| Prop | Type | Default |
|---|---|---|
children
| ReactNode | — |
openControlled open state. | boolean | — |
defaultOpenInitial open state when uncontrolled. | boolean | false |
onOpenChangeCalled with the next open state whenever the drawer opens or closes. | (open: boolean) => void | — |
sideEdge the drawer slides in from. | "start""end""top""bottom" | "end" |
sizeWidth ( | DrawerSize | "md" |
modal
| boolean | true |
closeOnOverlayPressClose when the backdrop is pressed (modal drawers only). | boolean | true |
closeOnEscapeClose on Escape. Only the topmost open drawer responds. | boolean | true |
swipeToCloseBottom sheets only: let users swipe the grab handle down to close. It's a shortcut; the Close button stays, so dragging is never required. | boolean | true |
initialFocusRefElement to focus when the drawer opens. Defaults to the first focusable element (usually the close button). | RefObject<HTMLElement | null> | — |
finalFocusRefElement to focus when the drawer closes. Defaults to | RefObject<HTMLElement | null> | — |
Drawer.Trigger
| Prop | Type | Default |
|---|---|---|
childrenThe visible label. | ReactNode | — |
startIconDecorative icon before the label. Hidden from assistive technology. | ReactNode | — |
endIconDecorative icon after the label. Hidden from assistive technology. | ReactNode | — |
loadingShows an inline spinner, sets | boolean | false |
loadingTextLabel shown (and announced) next to the spinner while | ReactNode | — |
loadingLabelAnnounced to screen readers when | string | "Loading" |
fullWidthStretches the button to fill its container. Inherits from a surrounding | boolean | false |
compactTighter side padding, so a short label (a page number, "OK") makes a button no wider than it is tall. | boolean | false |
variantVisual style. Inherits from a surrounding | "solid""soft""outline""ghost""link""inverse" | "solid" |
toneSemantic color. Inherits from a surrounding | "neutral""primary""accent""success""warning""danger""info" | "primary" |
sizeControl height, padding, and type size. Inherits from a surrounding | "sm""md""lg" | "md" |
radiusCorner rounding. When omitted, uses | "none""xs""sm""md""lg""xl""2xl""pill" | "pill" |
disabledDisables the control. Buttons use the native | boolean | false |
hrefPass a URL to render the control as a link ( | undefined | — |
asChildClone the single child element instead of wrapping | boolean | false |
Also accepts standard HTML attributes, plus className, style and ref.
Drawer.Content
| Prop | Type | Default |
|---|---|---|
childrenHeader, body, and footer parts. | ReactNode | — |
hideCloseButtonHide the built-in close button in the top corner. Only do this if the drawer has another visible | boolean | false |
closeLabelAccessible name of the built-in close button. | string | "Close" |
overlayClassNameExtra class for the backdrop (modal drawers only). | string | — |
containerElement to portal into. | HTMLElement | null | document.body |
Also accepts native <div> attributes, plus className, style and ref.
Drawer.Header
| Prop | Type | Default |
|---|---|---|
childrenUsually a | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Drawer.Title
| Prop | Type | Default |
|---|---|---|
asHeading level to render. Pick the one that fits the page outline. | "h1""h2""h3""h4""h5""h6" | "h2" |
childrenRequiredThe 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
| Prop | Type | Default |
|---|---|---|
childrenSupporting text. The dialog is | ReactNode | — |
Also accepts native <p> attributes, plus className, style and ref.
Drawer.Body
| Prop | Type | Default |
|---|---|---|
childrenThe main content. Scrolls when it's taller than the drawer. | ReactNode | — |
flushDrop 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. | boolean | false |
Also accepts native <div> attributes, plus className, style and ref.
Drawer.Footer
| Prop | Type | Default |
|---|---|---|
childrenActions (e.g. "Apply" and "Reset"). Stays visible while the body scrolls. | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Drawer.Close
| Prop | Type | Default |
|---|---|---|
childrenThe visible label. | ReactNode | — |
startIconDecorative icon before the label. Hidden from assistive technology. | ReactNode | — |
endIconDecorative icon after the label. Hidden from assistive technology. | ReactNode | — |
loadingShows an inline spinner, sets | boolean | false |
loadingTextLabel shown (and announced) next to the spinner while | ReactNode | — |
loadingLabelAnnounced to screen readers when | string | "Loading" |
fullWidthStretches the button to fill its container. Inherits from a surrounding | boolean | false |
compactTighter side padding, so a short label (a page number, "OK") makes a button no wider than it is tall. | boolean | false |
variantVisual style. Inherits from a surrounding | "solid""soft""outline""ghost""link""inverse" | "solid" |
toneSemantic color. Inherits from a surrounding | "neutral""primary""accent""success""warning""danger""info" | "primary" |
sizeControl height, padding, and type size. Inherits from a surrounding | "sm""md""lg" | "md" |
radiusCorner rounding. When omitted, uses | "none""xs""sm""md""lg""xl""2xl""pill" | "pill" |
disabledDisables the control. Buttons use the native | boolean | false |
hrefPass a URL to render the control as a link ( | 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)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 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
| Key | Action |
|---|---|
| EnterSpace | On the trigger: opens the drawer. |
| Escape | Closes the drawer (non-modal: only while focus is inside it). |
| TabShift+Tab | Moves 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
| Element | Role | States and properties |
|---|---|---|
Drawer.Content | dialog | aria-modal when modal, aria-labelledby → title, aria-describedby → description |
| Trigger | button | aria-haspopup="dialog", aria-expanded, aria-controls |
| Close button | button | aria-label |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every 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) |
| Focus | Focus 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 readers | Names, 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) |
| Color | Meaning 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 reflow | At 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 targets | Click 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) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |