Components / Overlays
Drawer
Side panel built on the native <dialog>, like Dialog: for filters, details and mobile navigation.
import { Drawer } from "@stylhero/ui";
Example
Code
import { useState } from "react";
import { Button, CheckboxGroup, Drawer } from "@stylhero/ui";
function DrawerExample() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Filters</Button>
<Drawer open={open} onClose={() => setOpen(false)} title="Filters" footer={<Button fullWidth onClick={() => setOpen(false)}>Show results</Button>}>
<CheckboxGroup legend="Brand" options={["AMD", "Intel", "NVIDIA"]} />
</Drawer>
</>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
onClose required |
() => void |
- | |
open required |
boolean |
- | |
title required |
ReactNode |
- | |
children |
ReactNode |
- | |
footer |
ReactNode |
- | |
side |
"right" | "left" | "bottom" |
"right" |
Which edge it slides from. Bottom becomes a sheet on phones. |
Also takes every <dialog> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Keyboard
| Key | Does |
|---|---|
| Tab | Stays inside the drawer |
| Esc | Closes it (calls onClose) |
Accessibility
- Built on the native
<dialog>opened withshowModal(): the browser traps focus, makes the page behind it inert and returns focus to the opener on close. - Labelled by its
title.
Generated from src/components/Drawer.tsx. Something wrong or missing? Open an issue.