Overlays
Drawer
A panel that slides up from the bottom, for details and quick actions, especially on phones.
Installation
npx sinaui add drawerCopy src/lib/ui/Drawer.svelte, Icon.svelte and tokens.css. No other dependencies.
Examples
Basic
Drag the handle down, or flick it, to close; let go early and it springs back.
<script lang="ts">
import Button from '#lib/ui/Button.svelte';
import Drawer from '#lib/ui/Drawer.svelte';
let open = $state(false);
const hours = [
['Saturday – Wednesday', '8:00 – 20:00'],
['Thursday', '8:00 – 14:00'],
['Friday', 'Closed for Jumuʿah']
];
</script>
<Button variant="secondary" onclick={() => (open = true)}>Reading room hours</Button>
<Drawer bind:open title="Bayt al-Ḥikma, Baghdad" description="Reading room hours this week.">
<dl>
{#each hours as [days, time] (days)}
<div>
<dt>{days}</dt>
<dd>{time}</dd>
</div>
{/each}
</dl>
{#snippet footer()}
<Button variant="ghost" onclick={() => (open = false)}>Not now</Button>
<Button onclick={() => (open = false)}>Book a seat</Button>
{/snippet}
</Drawer>
<style>
dl {
display: grid;
gap: 0.5rem;
margin: 0;
}
dl div {
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.625rem 0.75rem;
border-radius: var(--ui-radius);
background: var(--ui-subtle);
}
dd {
margin: 0;
color: var(--ui-muted);
font-variant-numeric: tabular-nums;
}
</style>Props
| Prop | Type | Default |
|---|---|---|
open | boolean, bindable | false |
title | string (required) | |
description | string | |
closeLabel | string | 'Close' |
footer | Snippet |
Accessibility
- A modal dialog: the page behind can't be reached, Escape closes, and focus goes back where it was.
- It opens on itself, so its title is read first.
- Dragging is a shortcut; the Close button and Escape do the same.