# Fields and choices · Divan

> Fields are filled shapes with the label above and a hint below. Choices are lists to tap; on/off settings are switches.

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

## Rules

- Use Field.Field, Field.Label, Field.Description and Field.Error around Input, Textarea or Select.
- Handles, e-mails, phone numbers and codes: dir="ltr" on the field.
- Words people write in either language: dir="auto" on the field, so what they type reads in its own direction (text that starts with a Latin @handle or #tag takes it from its words instead: Input and Textarea do it with fieldDir, the Composer with promptDir); what people wrote is shown with <Written text={…} />, each handle and tag in a <bdi>. An empty field starts where the page starts, its placeholder and caret too: layout.css keeps it there while a placeholder shows, Input and Textarea when it has none.
- A search with a magnifier is SearchField: its field has dir="auto" and the icon’s room stays at the start of the page’s line whatever direction the query takes; never a SearchIcon placed by hand beside an Input.
- Show limits up front (a counter like 6/30) instead of an error after the fact.
- A form checks its own fields: novalidate on the <form>, FormGuide (#lib/form-guidance.svelte.js) on submit, and Field.Error under each field to fix, in the page’s language. Never the browser’s popup, which speaks the browser’s language (pnpm divan:lint flags a form without novalidate whose fields the browser would check).
- Settings: a Switch with a label and one line on what it does when on.
- Picking several things (rows, lists, cards) is a Checkbox, an on/off setting is a Switch, one of a few visible options is a RadioGroup, one of many is a Select. Never the browser’s own checkbox or radio (pnpm divan:lint flags them).
- A group of actions that depends on a pick shows only when something is picked (a quiet muted panel: the count, then the actions); with nothing picked, one faint line says how to start. Never a row of dimmed buttons with a caption each.
- Fields are 36px tall with text-callout (14px). On touch screens layout.css keeps their text at 16px, so iPhone does not zoom in; never raise a field’s height or text size by hand.
- A day picked from a month (a booking, a class) is Calendar: calendar="persian" or "gregorian", and lang for its words, digits and direction. Its value is ISO Gregorian text (YYYY-MM-DD) whichever calendar shows it; days with nothing free are dimmed through isDateUnavailable, never refused after a press. Never bits-ui’s Calendar on its own: its arrows run backwards in Persian (pnpm divan:lint flags it: calendar-by-hand).

## Components

### Field

Label, control, hint and guidance for one form field.

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

```svelte
<Field.Field>
	<Field.Label for="handle">YouTube handle</Field.Label>
	<Input id="handle" name="handle" dir="ltr" aria-invalid={!ok} />
	{#if ok}<Field.Description>The @name under your channel title.</Field.Description>
	{:else}<Field.Error>Write your handle like @yourchannel.</Field.Error>{/if}
</Field.Field>
```

### Input

Single-line text, e-mail, number, file.

```ts
import { Input } from '#lib/components/ui/input/index.js';
```

```svelte
<Input id="mobile" name="mobile" inputmode="numeric" dir="ltr" placeholder="0912 345 6789" />
```

### Textarea

Multi-line text; grows with its content.

```ts
import { Textarea } from '#lib/components/ui/textarea/index.js';
```

```svelte
<Textarea id="message" name="message" placeholder="Optional" />
```

### Select

Choosing one of several options. Unavailable options disabled with the reason in their label.

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

```svelte
<Select.Root type="single" name="round" bind:value={round}>
	<Select.Trigger class="w-full">{label}</Select.Trigger>
	<Select.Content>
		<Select.Item value="3" label="Round 3 · Rostam" />
		<Select.Item value="4" label="Round 4 · opens with the next episode" disabled />
	</Select.Content>
</Select.Root>
```

### Switch

On/off settings. Turquoise when on.

```ts
import { Switch } from '#lib/components/ui/switch/index.js';
```

```svelte
<Field.Field orientation="horizontal">
	<Field.Content>
		<Field.Label for="emails">New-round e-mails</Field.Label>
		<Field.Description>An e-mail when a new round opens.</Field.Description>
	</Field.Content>
	<Switch id="emails" name="emails" bind:checked={emails} />
</Field.Field>
```

### Checkbox

Agreeing to something, or picking several items.

```ts
import { Checkbox } from '#lib/components/ui/checkbox/index.js';
```

```svelte
<Field.Field orientation="horizontal">
	<Checkbox id="terms" name="terms" bind:checked={terms} />
	<Field.Label for="terms" class="font-normal">I have read the terms</Field.Label>
</Field.Field>
```

### RadioGroup

One of a few visible options, as tappable rows.

```ts
import * as RadioGroup from '#lib/components/ui/radio-group/index.js';
```

```svelte
<RadioGroup.Root bind:value={amount} name="amount">
	<Field.Label for="a1">
		<Field.Field orientation="horizontal">
			<RadioGroup.Item value="50000" id="a1" />
			<Field.Content><Field.Title>50,000 toman</Field.Title></Field.Content>
		</Field.Field>
	</Field.Label>
</RadioGroup.Root>
```

### Calendar

Choosing a day on a Persian or Gregorian month grid; dims days with nothing free.

```ts
import { Calendar } from '#lib/components/ui/calendar/index.js';
```

```svelte
<!-- day is ISO Gregorian text (2026-12-09), whichever calendar shows it -->
<Calendar bind:value={day} calendar="persian" lang="fa" min={today} isDateUnavailable={(iso) => !free.has(iso)} />
<Calendar bind:value={day} calendar="gregorian" lang="en" />
```
