Drawer
A drawer component that slides in from the edge of the screen.
Drawer — bottom sheet mobile-friendly avec drag handle. Contrairement au Sheet (desktop, slide depuis un bord), le Drawer est optimisé pour mobile : il monte depuis le bas et se referme par un swipe down.
Pour un formulaire ou un flow d'action ciblé mobile, le Drawer est plus naturel qu'un Dialog qui prend tout l'écran ou un Sheet qui glisse depuis le bord.
Installation
$ bext ui add drawer
Copy and paste the following into src/components/ui/drawer.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="drawer" hooks.
Usage
Anatomy
<Drawer>
├── <DrawerTrigger for="drawer-id">
│ └── <Button>Open</Button>
└── <DrawerContent id="drawer-id">
└── ...contenu libre...API Reference
DrawerTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| for | string | — | Match l'id du Content. |
DrawerContent
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | — | Match Trigger.for. |
| className | string | — | Défaut : fixed inset-x-0 bottom-0, bg-background rounded-t-lg border-t, avec drag handle en haut. |
Data Attributes
Attributs qu'on peut cibler en CSS custom pour override le style par état.
| Attribute | On | Values | Description |
|---|---|---|---|
| data-ui="toggle-pop" | Trigger | data-target="#id" | Cliquer ouvre. |
| data-overlay | Content | hidden | Modal. |
Keyboard
| Key | Action |
|---|---|
| Escape | Ferme. |
Accessibility
Content porte role="dialog". Sur mobile, le drag handle est un affordance visuel mais pas nécessaire — Escape et le clic backdrop ferment aussi.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page