Overlays
Sheet
A panel that slides in from an edge of the screen. Use it for navigation on phones, filters and short forms that should keep the page in view.
import * as Sheet from '@statix/ui/sheet';Playground
<Sheet.Root>
<Sheet.Trigger>
{#snippet child({ props })}
<Button variant="outline" {...props}>Open sheet</Button>
{/snippet}
</Sheet.Trigger>
<Sheet.Content>
<Sheet.Header>
<Sheet.Title>Backups for yoga-berger.de</Sheet.Title>
<Sheet.Description>We back up every night at 03:10 and keep each backup for 30 days.</Sheet.Description>
</Sheet.Header>
<Sheet.Footer>
<Button>Back up now</Button>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root>Examples
Mobile navigation
The customer area menu on phones. It slides in from the left and leaves a 48px strip of the page visible, so people know they can tap out.
<script lang="ts">
import * as Sheet from '@statix/ui/sheet';
import { Button } from '@statix/ui/button';
import MenuIcon from '@lucide/svelte/icons/menu';
import LayoutGridIcon from '@lucide/svelte/icons/layout-grid';
import GlobeIcon from '@lucide/svelte/icons/globe';
import AtSignIcon from '@lucide/svelte/icons/at-sign';
import MailIcon from '@lucide/svelte/icons/mail';
import HistoryIcon from '@lucide/svelte/icons/history';
import ReceiptIcon from '@lucide/svelte/icons/receipt';
import PhoneIcon from '@lucide/svelte/icons/phone';
const links = [
{ label: 'Overview', href: '#overview', icon: LayoutGridIcon, current: true },
{ label: 'Websites', href: '#websites', icon: GlobeIcon },
{ label: 'Domains', href: '#domains', icon: AtSignIcon },
{ label: 'Mailboxes', href: '#mailboxes', icon: MailIcon },
{ label: 'Backups', href: '#backups', icon: HistoryIcon },
{ label: 'Invoices', href: '#invoices', icon: ReceiptIcon }
];
</script>
<Sheet.Root>
<Sheet.Trigger>
{#snippet child({ props })}
<Button variant="outline" size="icon" aria-label="Open menu" {...props}>
<MenuIcon />
</Button>
{/snippet}
</Sheet.Trigger>
<Sheet.Content side="left">
<Sheet.Header>
<Sheet.Title>Menu</Sheet.Title>
<Sheet.Description>Signed in as Anna Berger</Sheet.Description>
</Sheet.Header>
<nav aria-label="Customer area" class="px-3">
<ul class="grid gap-0.5">
{#each links as link (link.href)}
<li>
<a
href={link.href}
aria-current={link.current ? 'page' : undefined}
class="flex h-control-md items-center gap-3 rounded-full px-4 text-ink hover:bg-accent aria-[current=page]:bg-secondary aria-[current=page]:font-medium"
>
<link.icon class="size-[1.15em] text-ink-2" />
{link.label}
</a>
</li>
{/each}
</ul>
</nav>
<Sheet.Footer>
<div class="grid gap-3 rounded-lg bg-secondary p-4">
<p class="text-small text-ink-2">Questions? Jonas Weber from support is there for you.</p>
<Button variant="dark" href="tel:+4940468970790">
<PhoneIcon data-icon="inline-start" />
040 468 970 790
</Button>
</div>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root>Sides
The edge facing the page gets the 28px card radius. The others sit flush with the screen.
<script lang="ts">
import * as Sheet from '@statix/ui/sheet';
import { Button } from '@statix/ui/button';
const sides = ['top', 'right', 'bottom', 'left'] as const;
</script>
{#each sides as side (side)}
<Sheet.Root>
<Sheet.Trigger>
{#snippet child({ props })}
<Button variant="outline" class="capitalize" {...props}>{side}</Button>
{/snippet}
</Sheet.Trigger>
<Sheet.Content {side}>
<Sheet.Header>
<Sheet.Title>Backups for yoga-berger.de</Sheet.Title>
<Sheet.Description
>We back up every night at 03:10 and keep each backup for 30 days.</Sheet.Description
>
</Sheet.Header>
<Sheet.Footer>
<Sheet.Close>
{#snippet child({ props })}
<Button variant="outline" {...props}>Close</Button>
{/snippet}
</Sheet.Close>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root>
{/each}With a form
Short forms fit well in a right-hand sheet. Connect the submit button in the footer to the form with the form attribute.
<script lang="ts">
import * as Sheet from '@statix/ui/sheet';
import { Button } from '@statix/ui/button';
import { Input } from '@statix/ui/input';
import { Label } from '@statix/ui/label';
let open = $state(false);
</script>
<Sheet.Root bind:open>
<Sheet.Trigger>
{#snippet child({ props })}
<Button variant="outline" {...props}>Edit billing address</Button>
{/snippet}
</Sheet.Trigger>
<Sheet.Content>
<Sheet.Header>
<Sheet.Title>Billing address</Sheet.Title>
<Sheet.Description>We print it on your next invoice.</Sheet.Description>
</Sheet.Header>
<form
id="billing-address"
class="grid gap-4 px-6 py-2"
onsubmit={(event) => {
event.preventDefault();
open = false;
}}
>
<div class="grid gap-2">
<Label for="billing-company">Company</Label>
<Input id="billing-company" value="Yoga Studio Berger" />
</div>
<div class="grid gap-2">
<Label for="billing-street">Street</Label>
<Input id="billing-street" value="Lange Reihe 12" />
</div>
<div class="grid grid-cols-[1fr_2fr] gap-3">
<div class="grid gap-2">
<Label for="billing-zip">Postcode</Label>
<Input id="billing-zip" value="20099" />
</div>
<div class="grid gap-2">
<Label for="billing-city">City</Label>
<Input id="billing-city" value="Hamburg" />
</div>
</div>
</form>
<Sheet.Footer class="sm:flex-row sm:justify-end">
<Sheet.Close>
{#snippet child({ props })}
<Button variant="ghost" {...props}>Cancel</Button>
{/snippet}
</Sheet.Close>
<Button type="submit" form="billing-address">Save address</Button>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root>Bottom sheet
A list of actions for one item, for phones. Wrap each action in Sheet.Close so the sheet closes after a tap.
<script lang="ts">
import * as Sheet from '@statix/ui/sheet';
import { Button } from '@statix/ui/button';
import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import ExternalLinkIcon from '@lucide/svelte/icons/external-link';
import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw';
import DownloadIcon from '@lucide/svelte/icons/download';
const actions = [
{ label: 'Open website', icon: ExternalLinkIcon },
{ label: 'Restore a backup', icon: RotateCcwIcon },
{ label: 'Download backup', icon: DownloadIcon }
];
</script>
<Sheet.Root>
<Sheet.Trigger>
{#snippet child({ props })}
<Button variant="secondary" size="icon" aria-label="Actions for yoga-berger.de" {...props}>
<EllipsisIcon />
</Button>
{/snippet}
</Sheet.Trigger>
<Sheet.Content side="bottom" class="mx-auto max-w-lg">
<Sheet.Header>
<Sheet.Title>yoga-berger.de</Sheet.Title>
<Sheet.Description>Last backup today at 03:10</Sheet.Description>
</Sheet.Header>
<div class="grid gap-1 px-3 pb-6">
{#each actions as action (action.label)}
<Sheet.Close>
{#snippet child({ props })}
<button
{...props}
class="flex h-control-lg items-center gap-3 rounded-lg px-4 text-left text-ink hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none"
>
<action.icon class="size-5 text-ink-2" />
{action.label}
</button>
{/snippet}
</Sheet.Close>
{/each}
</div>
</Sheet.Content>
</Sheet.Root>Guidelines
Do
- Use left for navigation and right for details, filters and forms.
- Use bottom on phones for a short list of actions.
- Keep the content short enough to scan. The sheet scrolls, but long sheets feel like a page.
Don't
- Don’t use a sheet for a yes or no question. Use Dialog or Alert Dialog.
- Don’t open a sheet from another sheet.
Accessibility
- Built on the bits-ui Dialog: role="dialog", aria-modal, named by Sheet.Title.
- Focus moves into the sheet, stays trapped and returns to the trigger on close.
- Escape and a click on the scrim close it.
- Icon-only triggers need an aria-label, for example "Open menu".
API reference
Sheet.Root
Holds the open state. Renders no element.
| Prop | Type | Default |
|---|---|---|
open bind | boolean Whether the sheet is open. | false |
onOpenChange | (open: boolean) => void Called when the sheet opens or closes. | – |
Sheet.Trigger
renders<button> and accepts its attributesOpens the sheet. Use the child snippet to render a Button.
Sheet.Content
renders<div> and accepts its attributesThe panel. Renders the portal and the scrim for you.
| Prop | Type | Default |
|---|---|---|
side | 'top' | 'right' | 'bottom' | 'left' Edge the panel slides in from. Left and right are 384px wide from 640px up. | 'right' |
showCloseButton | boolean Shows a ghost icon button in the top right corner. | true |
interactOutsideBehavior | 'close' | 'ignore' | 'defer-otherwise-close' | 'defer-otherwise-ignore' What a click on the scrim does. | 'close' |
portalProps | Dialog.PortalProps Props for the portal. | – |
ref bind | HTMLDivElement | null The panel element. | – |
class | ClassValue Merged with the side classes. | – |
| Data attribute | Meaning |
|---|---|
data-slot="sheet-content" | Always present. |
data-side | The current side. |
data-state | "open" or "closed". |
Sheet.Header
renders<div> and accepts its attributesTitle and description with 24px padding.
Sheet.Title
renders<div role="heading"> and accepts its attributesNames the sheet. 24px, semibold.
Sheet.Description
renders<div> and accepts its attributes15px in ink-2.
Sheet.Footer
renders<div> and accepts its attributesSticks to the bottom of the panel. Stacks its children by default.
Sheet.Close
renders<button> and accepts its attributesCloses the sheet.
Sheet.Overlay
renders<div> and accepts its attributesThe scrim, same as Dialog.Overlay.
sheetContentVariants
The tailwind-variants function behind Sheet.Content.