Drawer
A modal panel that slides in from the start edge over the screen, such as an app's sections, closed by Escape, the scrim, its Close button or a swipe toward the edge.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
title | string | The heading at the top of the panel, and the dialog's accessible name. | |
open | boolean | bindable(false) | Whether the drawer shows. Bind it with bind:open={name}; the trigger piece sets it. |
Pieces
| Piece | Means |
|---|---|
trigger | The control that opens the drawer. Focus returns to it on close. |
Children
The drawer's content, such as links to the app's sections.
States
| State | Looks like |
|---|---|
closed | Nothing but the trigger. |
open | A panel the drawer's width (at most 85% of the window) at the start edge, at full height, over the scrim. |
Accessibility
| role | dialog with aria-modal="true" |
| name | The title prop. |
| focus | On open, focus moves into the panel and Tab stays inside; on close it returns to the trigger. |
| keyboard | Escape closes it; Enter and Space press Close. |
| notes | A swipe left on the panel closes it. Right-to-left layouts are not mirrored yet: the panel stays on the left. |
Theme tokens
color.scrim color.surface color.ink shadow.lg space.2 space.4 text.heading
Example
<Drawer title="Sections" bind:open={menu}><Link href="/" label="Home" /></Drawer>