Divan

Components

Buttons

Capsules, never outlined. Filled copper leads, and there is one per view. Everything else is tinted, gray or plain.

Styles

variant="default" · Filled copper: the main action of the view

variant="tinted" · A second important action

variant="secondary" · Gray: everything else

variant="ghost" · Quiet: toolbars, lists, the header

variant="plain" · Copper text: inline and low-key

variant="destructive" · Soft red: anything negative or sensitive

Sizes and icons

32, 36 and 44px tall. Arrows turn around in Persian. An icon-only button always has a spoken label.

Busy and unavailable

Available after you sign in.

A press that takes a moment shows it on the button: a spinner in place of its icon, from 150 ms after the press until the work is done. Buttons do it by themselves for a page they open, a form they send and a promise their onclick returns (press the first one); pending={busy} does it for anything else, and keeps the button’s colour: it is working, not unavailable. A dimmed button always has a short caption that says what makes it available.

Code

Button · Every pressable action. One variant="default" (filled copper) per view. Anything with a negative or sensitive meaning (disconnect, delete, remove, block, reject, end, sign out) is variant="destructive": its own soft red fill, never gray or copper with red text. While what it started is at work (a page it opens, a form it sends, a promise its onclick returns) it shows a spinner by itself; pending={busy} for anything else.

import { Button } from '#lib/components/ui/button/index.js';

<Button>Support Us</Button>
<Button variant="secondary">Copy Code</Button>
<Button variant="plain" size="sm">Try Again</Button>
<Button variant="destructive">Disconnect</Button>
<Button href="/fa/campaigns" variant="ghost">Campaigns</Button>

ConfirmButton · A second step in place before what is hard to take back (disconnect, delete, end a round): the first press turns the button into the question, with Cancel (focused) and the verb. Escape goes back. In a form the verb submits it; otherwise it calls onconfirm. Never the browser’s confirm().

import { ConfirmButton } from '#lib/components/ui/confirm-button/index.js';

<form method="POST" action="?/disconnect" use:enhance>
	<input type="hidden" name="platform" value="instagram" />
	<ConfirmButton type="submit" question="Disconnect @maryam.k?" detail="You can connect it again any time." confirmLabel="Disconnect">
		Disconnect
	</ConfirmButton>
</form>

<ConfirmButton question="Delete 3 cards?" confirmLabel="Delete" onconfirm={remove}>Delete</ConfirmButton>