# Sheets and toasts · Divan

> Sheets slide in for a task of their own. Dialogs only ask before something that can’t be undone. Toasts confirm, with Undo.

Part of Divan, the DivanWorks design system. Web page: https://brand.divanworks.com/sheets · All topics: https://brand.divanworks.com/llms.txt

## Rules

- On a phone a sheet scrolls as one column: give each part shrink-0. min-h-0 belongs only on a part that scrolls itself (overflow-y-auto); on another part the column squeezes it and its content spills over the next one.
- Which sheet is open lives in the address (UrlState), so a reload, the Back button or a shared link opens it again.
- Sheet side="bottom" on phones for short tasks; side="left"/"right" for menus and longer tasks. The drawer menu opens from the start side for the language and draws the same SideMenu as the desktop panel (brand.divanworks.com/side-menus); a task beside a side menu (managing lists, editing a card) opens from the end side, so the menu stays in view.
- A task never opens inside the page above or beside a view that fills the screen (a board, a table, a chart): that view shrinks to what is left. Managing, adding and editing open in a Sheet; its buttons stay in a footer while the rows scroll.
- Dialog: title is the question (“Delete the Round 2 campaign?”), two buttons: Cancel and the verb. No caution icon unless data is lost.
- toast() from svelte-sonner with an action { label: "Undo" } for undoable actions. Errors are never toasts.
- A pane beside a view that stays (the Dabir Room’s chat) is RoomPanel: docked beside the view from 1024px, which shrinks to what is left, and below a full-height bottom sheet over it with a step back named after the view (a gray capsule). Its links point at the page’s own address (?file=, ?dir=) and open it by shallow routing (goto(url, { shallow: true })), so the view never loads again and Back closes it; Escape closes it too, and the view is inert while the sheet covers it (bind:modal). Never a hand-made part that is fixed on phones and in the flow on wide screens (pnpm divan:lint: pane-by-hand).

## Components

### Sheet

A task of its own, or the drawer menu.

```ts
import * as Sheet from '#lib/components/ui/sheet/index.js';
```

```svelte
<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.

```ts
import { RoomPanel } from '#lib/components/ui/room-panel/index.js';
```

```svelte
<!-- 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.

```ts
import * as Dialog from '#lib/components/ui/dialog/index.js';
```

```svelte
<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.

```ts
import { Toaster } from '#lib/components/ui/sonner/index.js';
import { toast } from 'svelte-sonner';
```

```svelte
toast('Instagram disconnected', {
	description: 'Your support stays counted.',
	action: { label: 'Undo', onClick: reconnect }
});
```
