Components
Sheets and toasts
Sheets slide in for a task of their own, like editing your name. Dialogs ask only before something that can’t be undone. Toasts confirm what just happened, with Undo where it can be undone.
Toasts
Errors are never toasts: they belong next to what they are about (see Feedback).
Sheet
From the bottom on phones, from the side on wider screens. Rounded on every corner, floating a little away from the edges.
Room panel
What does the premise say?
Zal is born white-haired, and his father leaves him on the mountain. The premise says more.
- A pane beside a view that stays (the Dabir Room’s chat), for what a link in it opens. From 1024px it is docked beside the view, which shrinks to what is left; below, it is a full-height bottom sheet over it, with a step back named after the view.
- What it shows lives in the address (?file=, ?dir=) and opens by shallow routing: the view never loads again, and Back closes it.
- Escape closes it, the keyboard moves into it and back, and the view behind the sheet is inert meanwhile (bind:modal).
- It sits in the page’s own flow, beside its view: inside a section that waits to be drawn, a sheet fixed on a phone is fixed to that section instead.
Dialog
- Ask only before what can’t be undone. Disconnecting, hiding or archiving happens at once, with Undo.
- The title is the question, in the words of the action: “Delete the Round 2 campaign?”, never “Are you sure?”.
- Two buttons: Cancel, and the verb. No caution icon unless data is lost.
- On a phone a sheet scrolls as one column: each part keeps its own height (shrink-0), or a picture spills over the buttons under it.
- Which sheet is open lives in the address, so a reload or a shared link opens it again.
Code
Sheet · A task of its own, or the drawer menu.
import * as Sheet from '#lib/components/ui/sheet/index.js';
<Sheet.Root bind:open>
<Sheet.Trigger>{#snippet child({ props })}<Button variant="ghost" size="icon" aria-label="Menu" {...props}><MenuIcon /></Button>{/snippet}</Sheet.Trigger>
<!-- start for a menu, end for a task: the left or the right by the page’s language -->
<Sheet.Content side="start" dir={isFa ? "rtl" : "ltr"}>…</Sheet.Content>
</Sheet.Root>RoomPanel · A pane beside a view that stays (the Dabir Room’s chat), for what a link in it opens: docked beside the view from 1024px, which shrinks to what is left; below, a full-height bottom sheet over it, with a step back (a gray capsule named after the view) at its top. What it shows lives in the address and changes by shallow routing (goto(url, { shallow: true })), so the view never loads again and Back closes it; Escape closes it too, and the keyboard moves into it and back. bind:modal says when it covers the view, which the page makes inert meanwhile.
import { RoomPanel } from '#lib/components/ui/room-panel/index.js';
<!-- the room: the chat, and what a link in it opens beside it (?file=, ?dir=) -->
<div class="flex min-h-0 flex-1 gap-4">
<section class="flex min-w-0 flex-1 flex-col" inert={!!view && modal}>…the chat…</section>
<RoomPanel open={!!view} title={name} back="Chat" close="Close" onclose={() => show(null)} bind:modal>
{#snippet actions()}<Button variant="plain" size="sm" href={canonHref}>Open in the Canon</Button>{/snippet}
<FileView path={view.path} />
</RoomPanel>
</div>
<script>
// what the panel shows, from the address; a link to the page's own address opens it in place
const view = $derived(panelOf((page.shallow?.url ?? page.url).searchParams));
const show = (next) => goto(`${room}${panelSearch(new URLSearchParams(), next)}`, { shallow: true });
</script>Dialog · Only before what cannot be undone.
import * as Dialog from '#lib/components/ui/dialog/index.js';
<Dialog.Root>
<Dialog.Trigger>{#snippet child({ props })}<Button variant="secondary" {...props}>Delete Campaign…</Button>{/snippet}</Dialog.Trigger>
<Dialog.Content showCloseButton={false}>
<Dialog.Header>
<Dialog.Title>Delete the Round 2 campaign?</Dialog.Title>
<Dialog.Description>Its page and board are removed for good.</Dialog.Description>
</Dialog.Header>
<Dialog.Footer><Dialog.Close>Cancel</Dialog.Close><Button variant="destructive">Delete</Button></Dialog.Footer>
</Dialog.Content>
</Dialog.Root>Toaster · Confirm what just happened; Undo for undoable actions. Mount <Toaster /> once in the layout.
import { Toaster } from '#lib/components/ui/sonner/index.js';
import { toast } from 'svelte-sonner';
toast('Instagram disconnected', {
description: 'Your support stays counted.',
action: { label: 'Undo', onClick: reconnect }
});