Skip to content
Theme

Chapter 07 · Components

Components, A to Z.

A reference for the site, games, and Studio. Each lib/ui component has a section with production demos, usage snippets, and keyboard notes. Inspired by shadcn/ui, with an API for Svelte 5 and this site.

Components

63

Standalone

56

Compositions

7

Helpers

5

Arabic & RTL study

07.1 — How to use

Import, compose, done.

One file per component. Functions and types live in adjacent .ts files. Reuse existing components; if a pattern appears three times, add it to lib/ui and document it here.

TypeScript
import Button from '#lib/ui/button.svelte';
import Field from '#lib/ui/field.svelte';
import { toast } from '#lib/ui/toast.svelte.ts';

  • Built on Bits UI

    Focus trapping, Esc to close, arrows to navigate: ARIA behavior is reused.

  • Tokens for colors

    Tailwind v4 tokens bg, fg, surface, border-strong, and accent follow the light or dark theme.

  • Accessible from the start

    Required labels, consistent focus rings, touch targets ≥ 24 px, and respect for reduced motion.

  • Works without JavaScript

    Start with native POST forms, details, and select. JavaScript enhances them.

Composition recipes

Data table

Table + SortableTh + Pagination. The caller manages sorting and paging; Table remains a native <table>.

Svelte
<Table caption="Invoice terakhir.">
	<thead><tr>
		<th scope="col">Nomor</th>
		<SortableTh label="Total" align="right" dir={arah} onSort={urutkan} />
	</tr></thead>
	<tbody>{#each halamanIni as r (r.no)}…{/each}</tbody>
</Table>
<Pagination bind:page count={semua.length} perPage={20} />

Form

Field + Input + Button type="submit". Labels, hints, and server errors connect automatically.

Svelte
<form method="POST" use:enhance>
	<Field label="Email" error={form?.galat?.email} required>
		<Input type="email" name="email" />
	</Field>
	<Button type="submit" loading={mengirim}>Kirim</Button>
</form>

Studio filters

Attached ButtonGroup + Button href. State lives in the URL, preserving links with aria-current.

Svelte
<ButtonGroup label="Saringan" menempel>
	{#each SARINGAN as s (s.nilai)}
		<Button href="?status={s.nilai}" size="sm"
			variant={aktif === s.nilai ? 'secondary' : 'outline'}
			aria-current={aktif === s.nilai ? 'page' : undefined}>{s.nama}</Button>
	{/each}
</ButtonGroup>

07.2 — Components A–Z

63 of 63 components

accordion

Standalone Layout

FAQ list with one section open at a time.

TypeScript
import Accordion from '#lib/ui/accordion.svelte';

FAQ · one open
A company profile usually takes 2–4 weeks once all materials are ready.

open: lama

Usage

Svelte
<Accordion bind:value items={[{ value: 'a', title: 'Pertanyaan', content: 'Jawaban.' }]} />

Accessibility & keyboard

  • Each heading contains a button; Enter/Space opens or closes it.
  • Only one section opens at a time; opening another closes the previous one.
  • Content is plain text; use Collapsible for rich content.

alert

Standalone Feedback

Persistent page messages for information, success, warnings, or errors.

TypeScript
import Alert from '#lib/ui/alert.svelte';

Four variants

Fully booked this month

Next opening: November 2026.

Invoice paid

Rp 6,500,000 received on 17 October.

Due in 3 days

INV/2026/014 is unpaid.
Title only

Changes saved.

Usage

Svelte
<Alert variant="warning" title="Jatuh tempo 3 hari lagi">INV/2026/014 belum dibayar.</Alert>

Accessibility & keyboard

  • Only danger uses role="alert" for immediate announcements; others use role="status".
  • Icons and titles accompany colour; colour alone never carries the meaning.

alert-dialog

Standalone Overlay

Confirmation of irreversible actions, initially focused on Cancel.

TypeScript
import AlertDialog from '#lib/ui/alert-dialog.svelte';

Delete confirmation
Custom labels

Usage

Svelte
<AlertDialog
	title="Hapus INV/2026/014?"
	description="Tindakan ini tidak bisa dibatalkan."
	confirmLabel="Ya, hapus"
	onConfirm={hapus}
>
	{#snippet trigger(props)}<Button {...props} variant="danger">Hapus</Button>{/snippet}
</AlertDialog>

Accessibility & keyboard

  • Initial focus is Cancel; Tab stays within the dialog.
  • Esc cancels; clicking outside does not close it. A decision must be deliberate.
  • Closing returns focus to the trigger.

app-shell

Composition Layout

Studio shell with a desktop sidebar and mobile sliding panel.

TypeScript
import AppShell from '#lib/ui/app-shell.svelte';

Studio shell · resize for the sliding panel
Studio mobile navigation · sample data, available component

Usage

Svelte
<AppShell bind:collapsed>
	{#snippet rail(reveal)}<SpaceRail … />{/snippet}
	{#snippet menu(fold)}<StudioMenu space={usaha} active="leads" {fold} />{/snippet}
	{#snippet drawer(phone)}<StudioMenu space={usaha} active="leads" {phone} />{/snippet}
	{#snippet header()}<h1>Prospek</h1>{/snippet}
	{#snippet bottomNavigation(openMenu, ready, open)}…{/snippet}
	Isi halaman…
</AppShell>

Accessibility & keyboard

  • The keyboard-focused skip link moves focus to main. The sidebar is labelled Main navigation.
  • One sidebar snippet serves desktop and mobile, preventing divergent menus.
  • The mobile menu button is labelled Open menu; selecting a link closes the panel.
  • Content uses <main>; the full-height sidebar starts at 1024 px. Tablets use a menu panel. Inside another <main>, use elemenIsi="div".
  • The studio container follows available content width: use @min-[40rem]/studio:…. Headers may wrap.
  • Optional navigasiBawah(bukaMenu, siap, terbuka) exposes the same menu. The shell reserves space and preserves focus on resize. This preview uses real Studio navigation with sample data.

aspect-ratio

Standalone Layout

A frame preserving the content's width-to-height ratio.

TypeScript
import AspectRatio from '#lib/ui/aspect-ratio.svelte';

Three ratios
16 : 9
4 : 3
1 : 1

Usage

Svelte
<AspectRatio ratio={16 / 9} class="border-2 border-border">
	<img src={gambar} alt="Tangkapan layar beranda" class="size-full object-cover" />
</AspectRatio>

Accessibility & keyboard

  • Only the frame; content remains responsible for alternative text (img alt).
  • Ratios ≤ 0 fall back to 1:1 to prevent collapse.

avatar

Standalone Data

Person's photo, or initials when the image is missing or fails.

TypeScript
import Avatar from '#lib/ui/avatar.svelte';

Three sizes · initials
Sari Wulandari Sari Wulandari Sari Wulandari
With a name
Budi Santoso

Budi Santoso

CV Bangun Jaya

Usage

Svelte
<Avatar src={foto} alt="Sari Wulandari" fallback="SW" size="lg" />

Accessibility & keyboard

  • alt is required; if the image fails, initials are hidden from screen readers and alt is read.
  • Images are monochrome to match the editorial palette.

badge

Standalone Data

Short status labels such as paid, overdue, or new.

TypeScript
import Badge from '#lib/ui/badge.svelte';

Six variants
Neutral Solid Accent Paid Soon Overdue
With an icon
Done In 2 days

Usage

Svelte
<Badge variant="success">Lunas</Badge>

Accessibility & keyboard

  • Badge is text, not a control. Use Button for clickable actions.
  • Status must be explained by text, never colour alone.

breadcrumb

Standalone Navigation

Page location trail ending at the current page.

TypeScript
import Breadcrumb from '#lib/ui/breadcrumb.svelte';

Three levels
Custom labels

Usage

Svelte
<Breadcrumb
	label={m.remah_roti()}
	items={[{ label: 'Studio', href: '/studio' }, { label: 'Invoice', href: '/studio/invoices' }, { label: 'INV/2026/014' }]}
/>

Accessibility & keyboard

  • Wrapped in labelled <nav>; the default breadcrumb label can be localized by the caller.
  • The last item uses aria-current="page" and has no link.
  • The / separator is hidden from screen readers.

button

Standalone Actions

Button or button-styled link in eight variants and five sizes.

TypeScript
import Button from '#lib/ui/button.svelte';

Variant
  • primary — one per view: the primary action (cobalt).
  • accent — special highlights (archive yellow), not a replacement for primary.
  • secondary / outline / ghost — supporting actions, progressively quieter.
  • link — actions within sentences; tautan — the SEE ALL → pattern beneath a section.
  • danger — destructive actions only, with confirmation.
State matrix · normal, disabled, loading
Every button variant in normal, disabled, and loading states.
VariantNormalDisabledLoading
primary
accent
secondary
outline
ghost
link
tautan
danger
Sizes & icons
States & links

Usage

Svelte
<Button onclick={simpan} loading={menyimpan}>Simpan</Button>
<Button variant="outline" href="/studio/invoices">Semua invoice</Button>
<Button variant="tautan" size="sm" href="/process">Lihat prosesnya <ArrowRight /></Button>
<Button variant="ghost" size="icon-sm" aria-label="Tutup"><X /></Button>
<Button type="submit" name="tema" value="dark">Gelap</Button>

Accessibility & keyboard

  • The default type is button; use type="submit" explicitly to submit a form.
  • href renders an <a>: Enter follows the link; disabled is not applied.
  • loading sets aria-busy and blocks clicks to prevent duplicate submissions.
  • Icon-only buttons require aria-label; icon-sm (32 px) exceeds the 24 px minimum target.

button-group

Standalone Actions

Labelled button group, optionally joined into one segment.

TypeScript
import ButtonGroup from '#lib/ui/button-group.svelte';

Attached · filters (aria-current links)
Attached · theme segments (aria-pressed)

On the site these segments submit a POST form to /theme and work without JavaScript.

Spaced · icon toolbar

Usage

Svelte
<!-- Saringan Studio: keadaan di URL, jadi tetap tautan -->
<ButtonGroup label="Saringan" menempel>
	<Button href="?status=baru" size="sm" variant={aktif ? 'secondary' : 'outline'} aria-current={aktif ? 'page' : undefined}>Baru</Button>
	…
</ButtonGroup>

<!-- Tema tanpa JavaScript: form POST biasa -->
<form method="POST" action="/theme">
	<ButtonGroup label="Tema" menempel>
		<Button type="submit" name="tema" value="dark" size="sm" variant={aktif ? 'primary' : 'outline'} aria-pressed={aktif}>Gelap</Button>
	</ButtonGroup>
</form>

Accessibility & keyboard

  • role="group" requires a label so screen readers announce the group name.
  • Use aria-pressed for selected buttons or aria-current for links, never colour alone.
  • Attached groups scroll when space is tight; focus rings stay inside buttons.
  • Need one choice with left/right arrows? Use ToggleGroup.

calendar

Standalone Forms

Monthly calendar selecting one date as an ISO string.

TypeScript
import Calendar from '#lib/ui/calendar.svelte';

Single date
SMTWTFS
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

value: 2026-10-19

Usage

Svelte
<Calendar bind:value={tanggal} label="Tanggal rapat" />

Accessibility & keyboard

  • Arrows change days, PageUp/PageDown change months, Home/End jump to week boundaries.
  • Today is bold; selected text matches the selection background for readability.
  • Cells fit their container. min/max accept ISO limits; locale sets the calendar language.
  • Need a typeable input? Use DatePicker.

card

Standalone Layout

Framed panel with optional eyebrow, title, content, and footer.

TypeScript
import Card from '#lib/ui/card.svelte';

Complete · eyebrow, title, content, footer

Company profile · started 2 Oct

Toko Kue Bu Sari

Sari Wulandari

Sari Wulandari

Owner

Stage 3 / 7
Compact · with description

Notes

Materials incomplete

Waiting for the client's product photos and business description.

A content-only card without a header, with a hard shadow.

Footer · two actions in a narrow space

Invoice ready for review

Actions may wrap when space narrows.

Usage

Svelte
<Card eyebrow="Company profile · mulai 2 Okt" title="Toko Kue Bu Sari" class="shadow-pop">
	Isi kartu…
	{#snippet footer()}<Button size="sm" variant="ghost" class="ms-auto">Buka</Button>{/snippet}
</Card>

Accessibility & keyboard

  • Rendered as <article> with an <h3> title; keep heading order meaningful.
  • cn() merges extra classes; class="border-border" replaces the default border without conflict.

chart

Standalone Charts

Pure SVG bar or line charts with a keyboard- and touch-accessible data table.

TypeScript
import Chart from '#lib/ui/chart.svelte';

Bars
Leads per month
View data
Leads per month
PeriodeLeads
May3
Jun5
Jul2
Aug8
Sep6
Oct9
Grouped bars · filled and outlined
Money per month Paid Unpaid
View data
Money per month
PeriodePaidUnpaid
MayRp 4.5MRp 0
JunRp 0Rp 3M
JulRp 7.5MRp 0
AugRp 3MRp 4.5M
SepRp 12MRp 0
OctRp 6MRp 2.5M
Line with area
Cumulative income
View data
Cumulative income
PeriodeTotal paid
MayRp 4.5M
JunRp 4.5M
JulRp 12M
AugRp 15M
SepRp 27M
OctRp 33M
Three series · default colours
Project status per month New In progress Complete
View data
Project status per month
PeriodeNewIn progressComplete
Sep532
Oct754

Usage

Svelte
<Chart
	judul="Prospek per bulan"
	data={bulanan}
	sumbuX="b"
	seri={[{ kunci: 'prospek', label: 'Prospek', warna: 'var(--accent)' }]}
/>

Accessibility & keyboard

  • The chart has role="img" and a title; View data opens a keyboard- and touch-accessible table.
  • Four default colours are distinct; add custom colours for more series. Values must be nonnegative.
  • The Y axis uses whole numbers; zero-valued months remain visible.
  • Future or pending series use an outline, not only a different colour.

checkbox

Standalone Forms

Yes/no checkbox, including an indeterminate state.

TypeScript
import Checkbox from '#lib/ui/checkbox.svelte';

States

Three of five selected.

Error

Check to continue.

Usage

Svelte
<Field label="Saya setuju dengan ketentuan" inline>
	<Checkbox name="setuju" bind:checked={setuju} />
</Field>

Accessibility & keyboard

  • Space toggles the checkbox; Field inline also makes the adjacent label clickable.
  • indeterminate is announced as partially checked, useful for Select all.
  • The touch target extends 3 px on every side around the 18 px box.

code-block

Standalone Data

Syntax-coloured code with language icon, keyboard scrolling, and copy button.

TypeScript
import CodeBlock from '#lib/ui/code-block.svelte';

Svelte · markup and expressions
Svelte
<Button variant="primary" onclick={() => jumlah += 1}>
  Ditekan {jumlah} kali
</Button>

Terminal
Bash
bunx vitest run

Long · horizontal scroll
TypeScript
const rupiah = (n: number) => `Rp ${n.toLocaleString('id-ID')}`;
const total = baris.reduce((jumlah, b) => jumlah + b.harga * b.jumlah, 0); // baris panjang yang perlu digulir mendatar di layar sempit

JSON
JSON
{ "tema": "system", "aktif": true, "jumlah": 3 }

Usage

Svelte
<CodeBlock bahasa="ts" kode={cuplikan} />

Accessibility & keyboard

  • Focus <pre> with Tab and scroll with arrows so long code remains accessible.
  • Copy activates after JavaScript loads and reports its result through persistent status. Text can still be selected if clipboard access fails or JavaScript is off.
  • Syntax colours follow light, dark, or system theme, even before JavaScript. Code stays text, never executed HTML.
  • Language icons are decorative; the language name stays visible. Unsupported languages display plain text.

collapsible

Standalone Layout

Open/close section using native <details>, without JavaScript.

TypeScript
import Collapsible from '#lib/ui/collapsible.svelte';

Default · with icon
New work

open: false

Danger · destructive zone
Delete Studio account

All leads, clients, and invoices will also be deleted. Export your data first.

Lightweight · snippet heading
Klinik Gigi Senyum ok 17 Oct · 1.2 s

The model's redacted answer appears here.

CV Bangun Jaya error

Timed out; the visitor receives a friendly message.

Usage

Svelte
<Collapsible judul="Karya baru" ikon={Plus} bind:open={terbuka}>
	<form method="POST" action="?/add">…</form>
</Collapsible>

<Collapsible variant="ringan">
	{#snippet kepala()}Balasan <Badge>2</Badge>{/snippet}
	…
</Collapsible>

Accessibility & keyboard

  • Native <details>/<summary>: Enter or Space opens it, without JavaScript.
  • The summary uses the same focus ring as other controls.
  • Collapsed content remains searchable with the browser's Ctrl+F.

column-picker

Composition Data

Button to choose which table columns show, with a column count and a note for columns that do not fit.

TypeScript
import ColumnPicker from '#lib/ui/column-picker.svelte';

The caller stores the column choice
Sample invoices. Click a column header to sort.
Number Client Status Total (Rp)
INV/2026/009Toko Roti KenangaPaid4.500.000
INV/2026/010Warkop PojokIssued2.750.000
INV/2026/011Toko Roti KenangaVoid9.000.000
INV/2026/012Klinik SenyumIssued6.000.000
INV/2026/013Warkop PojokPaid1.250.000

Usage

Svelte
<ColumnPicker
	columns={columns.map((c) => ({ ...c, locked: c.key === 'number', fits: (c.priority ?? 1) <= level }))}
	bind:hidden
	{shown}
	label="Pilih kolom"
	countText={(shown, all) => `${shown} dari ${all} kolom`}
	noRoom="tidak muat"
	onchange={simpan}
/>

Accessibility & keyboard

  • Checkboxes inside a titled fieldset; the row-title column is locked and disabled.
  • The popover closes with Esc and focus returns to the button.

combobox

Standalone Forms

Typeable selection to filter long lists.

TypeScript
import Combobox from '#lib/ui/combobox.svelte';

Searchable select

value: gresik

Error & disabled

Choose a city.

Usage

Svelte
<Field label="Kota klien">
	<Combobox items={kota} bind:value name="kota" placeholder="Ketik nama kota…" />
</Field>

Accessibility & keyboard

  • Type to filter; arrows choose, Enter confirms, Esc closes.
  • Field automatically supplies id, aria-describedby, and aria-invalid.
  • Fewer than 8 options? Select or RadioGroup is easier to scan.

command-dialog

Composition Overlay

Searchable command dialog with arrows, Enter, and optional ⌘K.

TypeScript
import CommandDialog from '#lib/ui/command-dialog.svelte';

Command palette

Usage

Svelte
<CommandDialog bind:open groups={[{ heading: 'Halaman', items: [{ label: 'Invoice', keywords: ['tagihan'], onSelect: () => goto('/studio/invoices') }] }]} />
<!-- hotkey: ⌘K / Ctrl+K membuka dari mana saja — pasang SATU per halaman -->
<CommandDialog hotkey groups={…} />

Accessibility & keyboard

  • Focus starts in search; arrows choose, Enter runs, Esc closes.
  • keywords lets searches for tagihan find Invoice.
  • The list scrolls within short screens; a Close button supports touch.
  • Public callers can translate label and labelTutup.
  • This demo has no hotkey to avoid conflicts with the site's command palette.

context-menu

Standalone Overlay

Action menu opened by right-click or long press on touchscreens.

TypeScript
import ContextMenu from '#lib/ui/context-menu.svelte';

Context menu
Right-click here (long press on mobile)

Usage

Svelte
<ContextMenu items={aksi} class="block">
	<BarisInvoice {invoice} />
</ContextMenu>

Accessibility & keyboard

  • Open with right-click, long press, or Shift+F10/Menu while the trigger is focused.
  • Right-click is hard to discover; provide every action through ordinary buttons too.
  • Uses the same MenuEntry rows as Menu: items, labels, separators, and submenus.

data-table

Composition Data

Data table for analysis: column sorting, group subtotals, ledger totals, row selection, and a two-line list on phones.

TypeScript
import DataTable from '#lib/ui/data-table.svelte';

Sort, group by client, select rows
Sample invoices. Click a column header to sort.
INV/2026/009Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/010Warkop PojokIssued2.750.000—
INV/2026/011Toko Roti KenangaVoid9.000.000—
INV/2026/012Klinik SenyumIssued6.000.0001.500.000
INV/2026/013Warkop PojokPaid1.250.0001.250.000
Total 4 of 5 rows 14.500.0007.250.000
Studio design reference
A long table scrolls inside itself
Sample invoices. Click a column header to sort.
INV/2026/100Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/101Warkop PojokIssued2.750.000—
INV/2026/102Toko Roti KenangaVoid9.000.000—
INV/2026/103Klinik SenyumIssued6.000.0001.500.000
INV/2026/104Warkop PojokPaid1.250.0001.250.000
INV/2026/105Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/106Warkop PojokIssued2.750.000—
INV/2026/107Toko Roti KenangaVoid9.000.000—
INV/2026/108Klinik SenyumIssued6.000.0001.500.000
INV/2026/109Warkop PojokPaid1.250.0001.250.000
INV/2026/110Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/111Warkop PojokIssued2.750.000—
INV/2026/112Toko Roti KenangaVoid9.000.000—
INV/2026/113Klinik SenyumIssued6.000.0001.500.000
INV/2026/114Warkop PojokPaid1.250.0001.250.000
INV/2026/115Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/116Warkop PojokIssued2.750.000—
INV/2026/117Toko Roti KenangaVoid9.000.000—
INV/2026/118Klinik SenyumIssued6.000.0001.500.000
INV/2026/119Warkop PojokPaid1.250.0001.250.000
INV/2026/120Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/121Warkop PojokIssued2.750.000—
INV/2026/122Toko Roti KenangaVoid9.000.000—
INV/2026/123Klinik SenyumIssued6.000.0001.500.000
INV/2026/124Warkop PojokPaid1.250.0001.250.000
INV/2026/125Toko Roti KenangaPaid4.500.0004.500.000
INV/2026/126Warkop PojokIssued2.750.000—
INV/2026/127Toko Roti KenangaVoid9.000.000—
INV/2026/128Klinik SenyumIssued6.000.0001.500.000
INV/2026/129Warkop PojokPaid1.250.0001.250.000
Total 24 of 30 rows 87.000.00043.500.000

Usage

Svelte
<DataTable
	{columns}
	sections={[{ key: 'all', items: rows }]}
	rowKey={(r) => r.id}
	sort={{ key: 'due', dir: 'asc' }}
	sortHref={(key) => `?sort=${key}`}
	footers={[{ key: 'total', label: 'Total 6 dari 8 baris', values: totals, total: true }]}
	off={(r) => r.status === 'void'}
	bind:selected
	selectLabel={(r) => `Pilih ${r.number}`}
	{cell}
/>

Accessibility & keyboard

  • A real <table>: sort direction is read from aria-sort on the column header, and each header is a focusable link or button.
  • Each row checkbox is labelled with the row's name; the header checkbox selects every visible row.
  • Below 640 px of its own width, rows become a two-line list by column role; reading order for screen readers stays the same.
  • From 700 px of its own width, a long table scrolls inside its frame, as tall as the rest of the screen, with the header, first column, and total row kept in view. A short table gets no empty space; under 700 px the table scrolls with the page.

date-picker

Standalone Forms

Date input with individually typeable parts or calendar selection.

TypeScript
import DatePicker from '#lib/ui/date-picker.svelte';

Type or pick
Due date

value: 2026-11-01

Empty & disabled
Start date
Locked date
Server error
Date rejected

Check the date again.

Form · required, bounds, disabled
Appointment date

Choose 1–30 November 2026.

Locked date

Local demo; nothing is sent to the server.

Usage

Svelte
<DatePicker bind:value={jatuhTempo} name="due_date" label="Jatuh tempo" />

Accessibility & keyboard

  • Type each date part or change it with the up/down arrows.
  • The calendar button is labelled Open calendar; Calendar keyboard controls apply.
  • Field connects name, hints, errors, required, and disabled; clicking its label focuses the date.
  • name uses a native date input: submits ISO, validates required/min/max, and excludes disabled values from FormData.
  • Without JavaScript the native picker remains available; real saves still require server validation.

dialog

Standalone Overlay

Modal window with title, content, and action row.

TypeScript
import Dialog from '#lib/ui/dialog.svelte';

Form inside a dialog
Information only

Usage

Svelte
<Dialog bind:open title="Ubah data klien" description="…">
	{#snippet trigger(props)}<Button {...props} variant="outline">Ubah</Button>{/snippet}
	<Field label="Nama"><Input /></Field>
	{#snippet footer()}
		<Button variant="outline" onclick={() => (open = false)}>Batal</Button>
		<Button onclick={simpan}>Simpan</Button>
	{/snippet}
</Dialog>

Accessibility & keyboard

  • Focus stays inside; Esc or the labelled Close button closes the dialog.
  • Closing returns focus to the trigger.
  • Title and description connect through aria-labelledby/aria-describedby.
  • Long content scrolls within the dialog, not on the page behind it.

empty

Standalone Feedback

Empty state explaining the situation and offering a next step.

TypeScript
import Empty from '#lib/ui/empty.svelte';

md · full-page

No leads yet

Contact form messages appear here.

sm · inside a list

No matches

Try another term or clear the filters.

Usage

Svelte
<Empty icon={Inbox} title="Belum ada prospek" description="Pesan dari formulir kontak muncul di sini.">
	{#snippet action()}<Button size="sm" variant="outline">Bagikan tautan kontak</Button>{/snippet}
</Empty>
<Empty ukuran="sm" title="Tidak ada hasil" />

Accessibility & keyboard

  • The title is a <p>, not a heading, so it preserves page structure.
  • The icon is decorative (aria-hidden); explain the state in words.
  • Offer a next step when possible: button, link, or suggestion.

field

Composition Forms

Label, hint, and error automatically connected to the inner control.

TypeScript
import Field from '#lib/ui/field.svelte';

Label, hint, required

As written on your business sign.

Error & disabled

Email address incomplete: the domain is missing.

Inline · control on the left

Updates when each project stage finishes.

Side by side · hints preserve input alignment

Name printed on the invoice.

Usage

Svelte
<Field label="Email" hint="Untuk balasan." error={galat.email} required teksWajib={m.d_k_required()}>
	<Input type="email" name="email" />
</Field>

Accessibility & keyboard

  • Controls automatically receive id, aria-describedby for hints/errors, and aria-invalid.
  • Validation errors connect immediately through a getter-based context.
  • The * is hidden; screen readers hear teksWajib, localized as required.
  • inline puts Checkbox/Switch on the left, label and hint on the right.
  • In grids, Field content aligns at the top so hints do not shift neighbouring inputs.

grid

Standalone Layout

Editorial grid whose cells share one 2 px line.

TypeScript
import Grid from '#lib/ui/grid.svelte';

Ordered list · 1 → 2 → 4 columns
  1. 01

    Get acquainted

    1 day

  2. 02

    Design

    3–5 days

  3. 03

    Build

    1–3 weeks

  4. 04

    Handover

    1 day

Number grid · small Stat

New leads

4

Active projects

1

Unpaid

9.8M

Paid

8M

Usage

Svelte
<Grid elemen="ol" kolom={{ sm: 2, lg: 4 }}>
	{#each tahap as t (t.id)}
		<GridCell elemen="li">…</GridCell>
	{/each}
</Grid>

Accessibility & keyboard

  • Use semantic elements: ol/ul for ordered or unordered lists with elemen="li" cells; div for layout.
  • Lines are 1 px gaps over a line-coloured background; cells need a background (KisiSel uses bg-bg).
  • Fill the last row; empty slots show the line colour.

grid-cell

Standalone Layout

One Kisi cell; href makes the entire cell a link.

TypeScript
import GridCell from '#lib/ui/grid-cell.svelte';

Usage

Svelte
<GridCell href={l('/services')}>
	<h3 class="display text-3xl">Company profile</h3>
	<p class="text-muted">…</p>
</GridCell>

Accessibility & keyboard

  • With href the whole cell is one link; never nest other links or buttons inside.
  • An inset focus ring uses a negative offset so neighbouring cells cannot cover it.
  • Link content becomes its accessible name: keep it brief and put the title first.

hover-card

Standalone Overlay

Supplementary link preview on hover, never for essential content.

TypeScript
import HoverCard from '#lib/ui/hover-card.svelte';

Link preview

This project was made for — hover or focus the name.

Usage

Svelte
<HoverCard>
	{#snippet trigger(props)}<a {...props} href="/projects/qomunal">Qomunal</a>{/snippet}
	<p class="font-bold">PT Qomunal Media Pratama</p>
</HoverCard>

Accessibility & keyboard

  • Appears after 300 ms on hover or focus; Esc closes it.
  • Supplementary only: it does not appear on touchscreens, so keep essential content elsewhere.
  • The trigger stays a normal link that works without the card.

input

Standalone Forms

Single-line input forwarding all <input> attributes.

TypeScript
import Input from '#lib/ui/input.svelte';

Text & bind:value

Used in the reply greeting.

value: —

Other types

Native browser calendar; no extra library.

Usage

Svelte
<Field label="Nama">
	<Input name="nama" bind:value={nama} autocomplete="name" />
</Field>

Accessibility & keyboard

  • Always provide a label: use Field, or aria-label if a visible label exists elsewhere.
  • Appropriate types (email, tel, url, date) open the matching mobile keyboard.
  • Errors use a red border and Field error text, never colour alone.

input-group

Composition Forms

Input with leading icon and fixed prefixes or suffixes such as Rp or .id.

TypeScript
import InputGroup from '#lib/ui/input-group.svelte';

Prefixes & suffixes

An estimate only; may be left blank.

Leading icon

Account names allow letters, digits, dots, and underscores only.

Usage

Svelte
<Field label="Anggaran">
	<InputGroup prefix="Rp" suffix=",-" inputmode="numeric" name="anggaran" />
</Field>
<InputGroup ikon={Search} type="search" aria-label="Cari prospek" />

Accessibility & keyboard

  • Prefixes, suffixes, and icons are hidden from screen readers; include important units in the label.
  • The entire box gets a focus ring when its input is focused.
  • The icon is decorative; search still needs a label from Field or aria-label.

item

Standalone Layout

Framed row with leading media, title, description, and trailing action.

TypeScript
import Item from '#lib/ui/item.svelte';

Media, text, action

Company profile

Five pages and a contact form, finished in 3 weeks.

INV/2026/014

Toko Kue Bu Sari · due 1 Nov

Soon

Usage

Svelte
<Item judul="Company profile" deskripsi="5 halaman · selesai 3 minggu">
	{#snippet awal()}<Globe class="size-5" aria-hidden="true" />{/snippet}
	{#snippet aksi()}<Button size="sm" variant="outline">Pilih</Button>{/snippet}
</Item>

Accessibility & keyboard

  • The title is bold text, not a heading; use Card for document structure.
  • Trailing actions wrap to a new line on narrow screens.

kbd

Standalone Data

Keyboard key indicator, such as ⌘ or K.

TypeScript
import Kbd from '#lib/ui/kbd.svelte';

Shortcuts

Command palette: ⌘K or CtrlK

Send: Enter · new line: ⇧Enter

Usage

Svelte
<Kbd>⌘</Kbd><Kbd>K</Kbd>

Accessibility & keyboard

  • Native <kbd>; symbols like ⌘ are read literally, so include Ctrl for Windows.
  • Only a visual hint; implement the shortcut in the handling component.

label

Standalone Forms

Standalone label with required marker for controls outside Field.

TypeScript
import Label from '#lib/ui/label.svelte';

Default · required marker
Eyebrow · compact toolbar

Usage

Svelte
<Label for="kota" wajib>Kota</Label>
<Input id="kota" name="kota" required />

<Label for="urut" variant="eyebrow">Urutkan</Label>

Accessibility & keyboard

  • for must match the control id; clicking the label focuses the control.
  • Required fields show a hidden * and an accessible required label.
  • For forms, use Field to connect label, hints, and errors together.

menu

Standalone Overlay

Data-driven dropdown with items, checkboxes, radios, labels, and submenus.

TypeScript
import Menu from '#lib/ui/menu.svelte';
import type { MenuEntry } from '#lib/ui/menu-types';

Actions · icons, shortcuts, submenus, danger
Checkboxes & radio buttons

due date: visible · sort: terbaru

Usage

Svelte
<Menu items={aksi} align="end">
	{#snippet trigger(props)}
		<Button {...props} variant="outline" size="icon" aria-label="Aksi invoice"><MoreHorizontal /></Button>
	{/snippet}
</Menu>

Accessibility & keyboard

  • Enter/Space/Down opens; arrows move, letters jump to items, Esc closes.
  • Right arrow opens submenus; left arrow closes them.
  • Checkbox/radio menu items announce their state with menuitemcheckbox/menuitemradio.
  • Icon-only triggers require aria-label.

menubar

Standalone Navigation

Desktop-style menu bar with arrow-key navigation.

TypeScript
import Menubar from '#lib/ui/menubar.svelte';

Menu bar

Choose a menu with the mouse or arrow keys.

Usage

Svelte
<Menubar
	label="Editor"
	menus={[{ id: 'berkas', nama: 'Berkas', items: [{ id: 'simpan', nama: 'Simpan', aksi: simpan }] }]}
/>

Accessibility & keyboard

  • Left/Right changes menus, Down opens, Enter chooses, Esc closes.
  • For desktop-style tools only; website navigation uses NavigationMenu.
  • Unlike MenuEntry, its API needs only id, nama, and aksi per item.

native-select

Standalone Forms

Lightweight, mobile-friendly native <select> with control styling.

TypeScript
import NativeSelect from '#lib/ui/native-select.svelte';

With optgroup

Works before JavaScript has loaded.

value: kamar

Disabled

Usage

Svelte
<Field label="Urutkan">
	<NativeSelect name="urut" bind:value={urut}>
		<option value="baru">Terbaru</option>
		<option value="nominal">Nominal</option>
	</NativeSelect>
</Field>

Accessibility & keyboard

  • Native <select>: system picker on mobile, type-to-jump, no JavaScript required.
  • Chrome/Edge 135+ use base-select styling without JavaScript; other browsers use native pickers.
  • Field supplies id and aria-describedby automatically.
  • For styled groups or search, use Select or Combobox.

nav-list

Composition Navigation

Vertical sidebar navigation with icons, badges, and active page.

TypeScript
import NavList from '#lib/ui/nav-list.svelte';

Usage

Svelte
<NavList
	label="Kerja"
	active={halaman}
	items={[{ key: 'leads', label: 'Prospek', href: resolve('/studio/leads'), icon: Inbox, badge: 4 }]}
/>

Accessibility & keyboard

  • A labelled <nav>; aria-current="page" and an accent line mark the active page.
  • Numeric badges are read after the label, such as Leads 4.
  • Rows are 36 px high for comfortable touch targets.

navigation-menu

Standalone Navigation

Horizontal links with active-page indication and no dropdown panels.

TypeScript
import NavigationMenu from '#lib/ui/navigation-menu.svelte';

Usage

Svelte
<NavigationMenu label="Bagian halaman" items={[{ label: 'Ringkasan', href: '#ringkasan', aktif: true }]} />

Accessibility & keyboard

  • A labelled <nav>; the active link uses aria-current="page".
  • Unlike shadcn Navigation Menu, this is a link row with no dropdown panels.
  • Normal links: Tab moves, Enter follows.

pagination

Standalone Navigation

Page numbers always showing first, last, and neighbouring pages.

TypeScript
import Pagination from '#lib/ui/pagination.svelte';

120 rows · 10 per page

page: 4

Usage

Svelte
<Pagination bind:page count={total} perPage={20} />

Accessibility & keyboard

  • Wrapped in <nav aria-label="Pages">; the current page is marked and announced.
  • Previous/Next buttons have text labels and are disabled at either end.
  • First, last, and neighbouring pages stay visible; gaps use a hidden ellipsis.

pin-input

Standalone Forms

Per-digit one-time-code boxes backed by one native <input>.

TypeScript
import PinInput from '#lib/ui/pin-input.svelte';

One-time code

Enter six digits from your authenticator app.

You can also paste all six digits.

Disabled · four digits
1
2

Usage

Svelte
<PinInput name="kode" label="Kode sekali pakai" bind:value={kode} onComplete={verifikasi} />

Accessibility & keyboard

  • One native <input> supports pasting six digits, SMS/password-manager autofill, and forms without JavaScript.
  • inputmode="numeric" and autocomplete="one-time-code" enable mobile number entry.
  • Boxes alone are unclear: wrap with Field for label/hint/error, or supply label.

popover

Standalone Overlay

Small floating panel near its trigger.

TypeScript
import Popover from '#lib/ui/popover.svelte';

Panel with controls

Usage

Svelte
<Popover bind:open align="end">
	{#snippet trigger(props)}<Button {...props} variant="outline">Bagikan</Button>{/snippet}
	Isi interaktif…
</Popover>

Accessibility & keyboard

  • The trigger announces aria-expanded; opening moves focus into the panel.
  • Esc or an outside click closes it and restores trigger focus.
  • May contain controls, unlike text-only Tooltip.

progress

Standalone Feedback

Progress from 0–100, or indeterminate when the value is unknown.

TypeScript
import Progress from '#lib/ui/progress.svelte';

Determinate · button controlled
35%
Indeterminate

Usage

Svelte
<Progress value={persen} label="Unggah berkas" />
<Progress value={null} label="Memproses" />

Accessibility & keyboard

  • role="progressbar" with aria-valuenow; a required label explains the operation.
  • null means indeterminate, with a gentle pulse; other values clamp to 0–100.
  • Pulsing stops with prefers-reduced-motion.

radio-group

Standalone Forms

One choice among labelled options with optional hints.

TypeScript
import RadioGroup from '#lib/ui/radio-group.svelte';

With hints & disabled options

Included in the package.

+20% of package price.

+45% of package price.

value: rapi

Usage

Svelte
<RadioGroup name="desain" bind:value aria-label="Tingkat desain" items={[{ value: 'rapi', label: 'Rapi', hint: 'Termasuk paket.' }]} />

Accessibility & keyboard

  • One Tab stop per group; arrows move and select immediately.
  • Groups require aria-label or aria-labelledby.
  • Option ids derive from $props.id(), preventing collisions between identical groups.

resizable

Standalone Layout

Two panels dividing their width through a range control.

TypeScript
import Resizable from '#lib/ui/resizable.svelte';

Two panels

List

INV/2026/014, INV/2026/013, INV/2026/012.

Preview

Move the control above to divide the space.

Usage

Svelte
<Resizable label="Lebar daftar" bind:value={lebar}>
	{#snippet awal()}Daftar…{/snippet}
	{#snippet akhir()}Pratinjau…{/snippet}
</Resizable>

Accessibility & keyboard

  • This is a Slider, not a drag handle: arrows, Home, End, pointer, and touch work.
  • Values stay within 25–75% so neither panel disappears.
  • The visible label shows a percentage; screen readers receive the slider value.

scroll-area

Standalone Layout

Fixed-height scrollable area with keyboard support.

TypeScript
import ScrollArea from '#lib/ui/scroll-area.svelte';

Fixed height
  1. 09:00New lead received
  2. 09:04Invoice sent
  3. 09:08Reply sent
  4. 09:12New lead received
  5. 09:16Invoice sent
  6. 09:20Reply sent
  7. 09:24New lead received
  8. 09:28Invoice sent
  9. 09:32Reply sent
  10. 09:36New lead received
  11. 09:40Invoice sent
  12. 09:44Reply sent
  13. 09:48New lead received
  14. 09:52Invoice sent

Usage

Svelte
<ScrollArea label="Riwayat aktivitas" tinggi="12rem">…</ScrollArea>

Accessibility & keyboard

  • Tab can focus it; arrows/PageDown scroll, preventing keyboard traps.
  • A section aria-label gives the focused area a name.
  • overscroll-contain prevents end-of-area scrolling from moving the page.

select

Standalone Forms

Styled selection with groups and disabled options, submitted with forms.

TypeScript
import Select, { type SelectOption } from '#lib/ui/select.svelte';

Groups & disabled options

value: cp

Unselected · error

Choose a package to continue.

Usage

Svelte
<Field label="Paket">
	<Select items={paket} bind:value name="paket" required />
</Field>

Accessibility & keyboard

  • Enter/Space/arrows open; initial letters jump to options; Esc closes.
  • name submits a hidden input. Choices need hydration; use NativeSelect for forms without JavaScript.
  • Grouped options have headings; keyboard navigation skips disabled options.

separator

Standalone Layout

Horizontal or vertical separator line.

TypeScript
import Separator from '#lib/ui/separator.svelte';

Horizontal

Project overview

Stage 3 of 7 · Company profile

Vertical
Leads Clients Invoice

Usage

Svelte
<Separator />
<Separator vertikal />

Accessibility & keyboard

  • role="separator" with aria-orientation; a visual-semantic separator, not focusable.
  • For decorative inline separators, CSS borders suffice.

sheet

Standalone Overlay

Sliding panel from the right, left, or bottom edge.

TypeScript
import Sheet from '#lib/ui/sheet.svelte';

Right · details
Bottom · mobile filters

Usage

Svelte
<Sheet side="bottom" title="Saringan" description="…">
	{#snippet trigger(props)}<Button {...props} variant="outline">Saring</Button>{/snippet}
	Isi panel…
</Sheet>

Accessibility & keyboard

  • Modal dialog: focus stays inside; Esc or Close dismisses it and restores trigger focus.
  • hideTitle hides the title visually, but screen readers still announce it.
  • Bottom panels are thumb-friendly on mobile; reduced motion disables their movement.

skeleton

Standalone Feedback

Shimmering placeholder while content loads.

TypeScript
import Skeleton from '#lib/ui/skeleton.svelte';

List row
Game board

Usage

Svelte
<div aria-busy="true">
	<span class="sr-only">Memuat papan…</span>
	<Skeleton class="aspect-square w-full max-w-[34rem] border-2 border-border" />
</div>

Accessibility & keyboard

  • aria-hidden hides skeletons from screen readers; announce loading on the wrapper with aria-busy and sr-only text.
  • Shimmer stops with prefers-reduced-motion.
  • Match real content dimensions to prevent layout shifts.

slider

Standalone Forms

Slider for a single value or a two-value range.

TypeScript
import Slider from '#lib/ui/slider.svelte';

Single value

5 pages

Range

Budget: Rp 5 – 15 million

Usage

Svelte
<Slider label="Jumlah halaman" bind:value={halaman} min={1} max={12} name="halaman" />

Accessibility & keyboard

  • Arrows move one step, PageUp/PageDown ten; Home/End go to either end.
  • Each thumb is labelled; range controls use labels such as Budget 1 and Budget 2.
  • Show numeric values beside sliders; thumb position alone is insufficient.

sortable-th

Standalone Data

Sortable table heading with aria-sort on <th>.

TypeScript
import SortableTh, { type SortDir } from '#lib/ui/sortable-th.svelte';

Ascending → descending → original
Click the Project header to sort.
Clients
Toko Kue Bu Sari2
Klinik Gigi Senyum1
CV Bangun Jaya3

Usage

Svelte
<thead><tr>
	<SortableTh label="Total" align="right" dir={kunci === 'total' ? arah : null} onSort={() => urutkan('total')} />
</tr></thead>

Accessibility & keyboard

  • aria-sort belongs on <th> (ascending/descending/none), not the button.
  • Buttons are focusable; Enter/Space sorts. Arrow icons are decorative.
  • The caller stores sort direction; the component never sorts data itself.

spinner

Standalone Feedback

Small loading indicator announced by screen readers.

TypeScript
import Spinner from '#lib/ui/spinner.svelte';

Inline text
Fetching project data… Fetching project data…
In a button

Usage

Svelte
<Spinner label="Mengambil data proyek" />
<Button loading>Simpan</Button> <!-- Button memakai Spinner sendiri -->

Accessibility & keyboard

  • role="status" uses sr-only text, default Loading; supply a specific label.
  • Rotation stops with prefers-reduced-motion; adjacent text still explains the state.
  • Use the loading prop on buttons instead of nesting Spinner.

stat

Standalone Data

One labelled number with an optional upward or downward change.

TypeScript
import Stat from '#lib/ui/stat.svelte';

md size (default)

New leads

4

2 from last week

Active projects

1

Unpaid

9.8M

1 overdue

Paid this month

8M

2 million since September

sm · compact grid

Plays

128

Complete

97

Average

4:12

lg · primary figure

Income 2026

33M

12% from 2025

Colour follows the value's meaning

New leads

4

Already paid

8M

Awaiting payment

2M

Past due

1

Usage

Svelte
<Stat label="Belum dibayar" value="9,8 jt" delta="1 terlambat" trend="down" ukuran="sm" />

Accessibility & keyboard

  • Labels are read before values; tabular-nums keeps numeric columns aligned.
  • Trend direction is written in delta text; arrow icons are decorative.
  • warna reinforces meaning; labels still identify success, pending, or problems.

switch

Standalone Forms

On/off switch for settings applied immediately.

TypeScript
import Switch from '#lib/ui/switch.svelte';

States

Updates after each stage finishes.

notifications: on

Usage

Svelte
<Field label="Notifikasi email" inline>
	<Switch name="notifikasi" bind:checked={notifikasi} />
</Field>

Accessibility & keyboard

  • role="switch" uses aria-checked; Space/Enter toggles it.
  • For immediate settings; use Checkbox when changes apply only after submitting a form.
  • 24 px high, meeting the minimum touch target.

table

Standalone Data

Table wrapper scrolling inside its own frame.

TypeScript
import Table from '#lib/ui/table.svelte';

Data table recipe · Table + SortableTh + Pagination + Badge
Five latest invoices; click Client or Total to sort.
Number Status
INV/2026/012CV Bangun JayaPaidRp 8.000.000
INV/2026/014Toko Kue Bu SariOverdueRp 6.500.000
INV/2026/010Bengkel Maju MotorPaidRp 4.200.000

Usage

Svelte
<Table caption="Invoice terakhir.">
	<thead><tr><th scope="col">Nomor</th><th scope="col" class="num">Total</th></tr></thead>
	<tbody>
		{#each baris as r (r.no)}<tr><td>{r.no}</td><td class="num">{rupiah(r.total)}</td></tr>{/each}
	</tbody>
</Table>

Accessibility & keyboard

  • A native <table> with caption and th scope provides row-by-row screen-reader structure.
  • Scrolling stays inside its frame with gulir-x; mobile pages do not shift sideways.
  • Numeric cells use num: right-aligned, monospaced, tabular digits.

tabs

Standalone Navigation

Bold-underlined tabs switching panels on the same page.

TypeScript
import Tabs from '#lib/ui/tabs.svelte';

Three panels

Company profile project, stage 3 of 7.

Usage

Svelte
<Tabs bind:value items={[{ value: 'a', label: 'Ringkasan' }]}>
	{#snippet panel(v)}…{/snippet}
</Tabs>

Accessibility & keyboard

  • One Tab stop for the tab list; Left/Right moves, Home/End reaches either end.
  • The active panel is focusable next and named by its tab.
  • Tabs scroll horizontally without a visible scrollbar on narrow screens.

textarea

Standalone Forms

Multiline input whose height follows its content.

TypeScript
import Textarea from '#lib/ui/textarea.svelte';

Grows with content

0 / 500 karakter

Error & disabled

Billing address is required.

Usage

Svelte
<Field label="Ceritakan kebutuhannya">
	<Textarea name="pesan" bind:value maxlength={2000} />
</Field>

Accessibility & keyboard

  • Height follows content with field-sizing: content, without JavaScript or double scrolling.
  • Use maxlength for limits and show remaining characters as text.

toaster

Standalone Feedback

Temporary corner notices triggered with toast().

TypeScript
import { toast } from '#lib/ui/toast.svelte.ts';
// <Toaster /> sudah dipasang SEKALI di layout root.

Five forms

Usage

Svelte
toast({ title: 'Pesan terkirim', description: 'Dibalas dalam 1 hari kerja.', variant: 'success' });
toast({ title: 'Prospek diarsipkan', action: { label: 'Urungkan', onClick: kembalikan } });

Accessibility & keyboard

  • Status/alert regions stay mounted; visual buttons remain outside live regions.
  • Ordinary notices last 5 seconds; hover, internal focus, or hidden tabs pause the timer.
  • Action toasts persist until selected or dismissed. duration uses milliseconds; 0 means persistent.
  • The close target is 36 px; closing restores focus to an existing trigger.
  • toast() never runs on the server, so notices cannot leak between visitors.

toggle

Standalone Actions

Two-state button using aria-pressed.

TypeScript
import Toggle from '#lib/ui/toggle.svelte';

Text

pressed: false

Icon only · labelled

Usage

Svelte
<Toggle bind:pressed={arsip}>Tampilkan arsip</Toggle>
<!-- Ikon saja: baru di sini label dipakai -->
<Toggle bind:pressed={tebal} label="Tebal"><Bold /></Toggle>

Accessibility & keyboard

  • aria-pressed announces state; Space/Enter toggles it.
  • Visible text supplies the button name; use label only for icon-only content (WCAG 2.5.3).
  • Text stays unchanged when pressed; aria-pressed carries state, not a changing label.

toggle-group

Standalone Actions

Single-choice segmented control such as IDR/USD.

TypeScript
import ToggleGroup from '#lib/ui/toggle-group.svelte';

Two choices

value: idr

Three choices

Usage

Svelte
<ToggleGroup label="Mata uang" bind:value items={[{ value: 'idr', label: 'IDR' }, { value: 'usd', label: 'USD' }]} />

Accessibility & keyboard

  • One Tab stop; Left/Right moves, Space/Enter selects.
  • The group is labelled and announces the selected choice as pressed.
  • Segments keep single-line labels and scroll in narrow containers. Set min-w-0 on flex/grid parents; focus rings stay inside.
  • Requires JavaScript. Without it, use attached ButtonGroup with Button type="submit".

tooltip

Standalone Overlay

Single-line explanation when a control is hovered or focused.

TypeScript
import Tooltip from '#lib/ui/tooltip.svelte';

On an icon button

Usage

Svelte
<Tooltip content="Salin ke papan klip">
	{#snippet children(props)}
		<Button {...props} variant="ghost" size="icon" aria-label="Salin"><Copy /></Button>
	{/snippet}
</Tooltip>

Accessibility & keyboard

  • Appears on hover or keyboard focus after 250 ms; Esc hides it.
  • Supplementary only; it does not appear on touchscreens.
  • Icon buttons still need their own aria-label; a tooltip is not an accessible name.
  • Includes its own Provider; no global wrapper needed.

trace

Standalone Feedback

The steps of a process with status, counts, and references, folding once done.

TypeScript
import Trace from '#lib/ui/trace.svelte';

Running: open, later steps dimmed
  1. Question checked 1 personal details masked · passed
  2. Reading packages, work, and FAQ
  3. Writing the answer
  4. Checking prices and cards
Done: folded, open it to see the counts
Held and failed, with a Try again button
  1. Question checked 1 personal details masked · passed
  2. Site knowledge read 3 packages · 10 projects · 12 FAQ · 7 steps
  3. Answer written 4 sentences, each checked
  4. Answer held a price not in the catalog
  1. Question checked 1 personal details masked · passed
  2. Site knowledge read 3 packages · 10 projects · 12 FAQ · 7 steps
  3. Writing the answer cut off

Usage

Svelte
<Trace rows={traceRows(steps, 'done')} summary="4 langkah · 3,2 dtk" duration={fmt}>
	{#snippet action()}<Button size="sm" onclick={retry}>Coba lagi</Button>{/snippet}
</Trace>

Accessibility & keyboard

  • The summary is a button with aria-expanded; plain rows are not tab stops, linked rows are ordinary links.
  • Rows are not announced one by one; status is in the icon and the words, and the shimmer stops under reduced motion.

Feature components · AI

These live in features/ai. The Services page assistant uses Prompt with a real server; both demos here run without a model or network requests.

prompt

Feature AI

Single-message input with a character counter; the Services page assistant uses a real server.

TypeScript
import Prompt from '#lib/features/ai/prompt.svelte';

Local demo · no model

Usage

Svelte
<Prompt label="Tanya tentang layanan" bind:value busy={memuat} onsubmit={tanya} maxLength={500} />

Accessibility & keyboard

  • Enter sends, Shift+Enter adds a line; Japanese/Chinese IME composition never sends early.
  • While busy, the input is readonly and the button uses aria-busy.
  • The caller sends requests and displays results; the component knows nothing about models.

jejak

Feature AI

Actual process events, never a model's inner thoughts. Not used on live pages yet.

TypeScript
import Jejak from '#lib/features/ai/trace.svelte';

Sample steps · button controlled
  1. Receiving inputIn progress
  2. Checking limits and quotaWaiting
  3. AnsweringWaiting
  4. Redacting personal dataWaiting

Usage

Svelte
<Jejak label="Status permintaan" steps={[{ id: 'kirim', title: 'Mengirim', status: 'selesai' }]} />

Accessibility & keyboard

  • A labelled ordered list (<ol>); status is text and colour only reinforces it.
  • The caller must report real status; never invent a thinking state.

chatbot

Feature AI

Demo with scripted answers, no network.

TypeScript
import Chatbot from '#lib/features/chatbot/chatbot.svelte';

Demo with scripted answers, no network.

Usage

Svelte
<!-- (site)/+layout.svelte: the floating button; the panel loads on the first hover, focus, click, or #ask -->
<Chatbot engine={origin} {locale} {contactHref} position="right" page={path} />

Accessibility & keyboard

  • Conversation
  • Your question
  • A quick question

07.3 — Helpers

Helpers

Used by other components or the root layout, so they have no standalone demo.

Helper components in lib/ui.
NameCategoryPurpose
directionUtilitiesDirection and language context for controls and portals; original study at /design/rtl.
json-ldUtilitiesWrites safely escaped JSON-LD structured data into <head>.
menu-itemsUtilitiesShared menu rows rendered by Menu and ContextMenu.
navigation-progressFeedbackThin top-edge progress bar during slow page navigation.
page-transitionUtilitiesPage-content wrapper with a loading skeleton and rising fade-in.