# Choosing a control

Switch, Checkbox, RadioGroup, Select: they all pick a value. The right one tells people when it takes effect and how many they may pick.

API [Switch](/ui/storybook/?path=/docs/ui-primitives-switch--docs) [Checkbox](/ui/storybook/?path=/docs/ui-primitives-checkbox--docs) [RadioGroup](/ui/storybook/?path=/docs/ui-primitives-radiogroup--docs) [SegmentedControl](/ui/storybook/?path=/docs/ui-primitives-segmentedcontrol--docs) [Toolbar](/ui/storybook/?path=/docs/ui-toolbar--docs) [SplitButton](/ui/storybook/?path=/docs/ui-primitives-splitbutton--docs) [Toggle](/ui/storybook/?path=/docs/ui-primitives-toggle--docs) [Select](/ui/storybook/?path=/docs/ui-primitives-select--docs) [FilterMenu](/ui/storybook/?path=/docs/ui-filtermenu--docs) [DropdownMenu](/ui/storybook/?path=/docs/ui-primitives-dropdownmenu--docs) [NumberInput](/ui/storybook/?path=/docs/ui-primitives-numberinput--docs) [Slider](/ui/storybook/?path=/docs/ui-primitives-slider--docs) [Meter](/ui/storybook/?path=/docs/ui-primitives-meter--docs) [ColorPicker](/ui/storybook/?path=/docs/ui-colorpicker--docs) [Tabs](/ui/storybook/?path=/docs/ui-primitives-tabs--docs) [Frame](/ui/storybook/?path=/docs/ui-primitives-frame--docs) [ContentFrame](/ui/storybook/?path=/docs/ui-content-contentframe--docs) [Label](/ui/storybook/?path=/docs/ui-primitives-label--docs) [Button](/ui/storybook/?path=/docs/ui-primitives-button--docs)

**A Switch acts the moment it flips. A Checkbox waits for a submit, or picks items from a set. Exactly one of a few is a RadioGroup; exactly one of many is a Select.**

```tsx
import { LANGUAGES } from "@orz/fixtures/account.ts";
import { INBOX_THREADS } from "@orz/fixtures/inbox.ts";
import { Button } from "@orz/ui/components/button";
import { Checkbox } from "@orz/ui/components/checkbox";
import { EmptyState } from "@orz/ui/components/empty-state";
import { GroupHeading } from "@orz/ui/components/group-heading";
import { Label } from "@orz/ui/components/label";
import { List, ListItem } from "@orz/ui/components/list";
import { Pane } from "@orz/ui/components/pane";
import { RadioGroup, RadioGroupItem } from "@orz/ui/components/radio-group";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@orz/ui/components/select";
import { Switch } from "@orz/ui/components/switch";
import { ArchiveIcon } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";

const THREADS = INBOX_THREADS.filter(({ folder }) => folder === undefined)
  .slice(0, 4)
  .map(({ id, subject }) => ({ id, subject }));

const INDENTS = [
  { value: "2", label: "2 spaces" },
  { value: "4", label: "4 spaces" },
  { value: "tab", label: "Tabs" },
];

export function ControlsCompared() {
  const [threads, setThreads] = useState(THREADS);
  const [selected, setSelected] = useState<string[]>([]);
  const all = threads.length > 0 && selected.length === threads.length;
  const archive = () => {
    const before = threads;
    setThreads(threads.filter(({ id }) => !selected.includes(id)));
    setSelected([]);
    toast(
      selected.length === 1
        ? "Conversation archived"
        : `${selected.length} conversations archived`,
      { action: { label: "Undo", onClick: () => setThreads(before) } },
    );
  };
  return (
    <div className="grid grid-cols-1 gap-8 sm:grid-cols-2">
      <div className="grid grid-cols-1 content-start gap-3">
        <GroupHeading>Editor</GroupHeading>
        <div className="flex items-center justify-between gap-4 touch:min-h-touch">
          <Label htmlFor="cc-wrap">Wrap long lines</Label>
          <Switch id="cc-wrap" defaultChecked />
        </div>
        <div className="flex items-center justify-between gap-4 touch:min-h-touch">
          <Label htmlFor="cc-line-numbers">Show line numbers</Label>
          <Switch id="cc-line-numbers" defaultChecked />
        </div>
        <div className="flex items-center justify-between gap-4 touch:min-h-touch">
          <Label htmlFor="cc-language">New files open as</Label>
          <Select defaultValue="markdown">
            <SelectTrigger id="cc-language" className="w-36">
              <SelectValue />
            </SelectTrigger>
            <SelectContent>
              {LANGUAGES.map(({ value, label }) => (
                <SelectItem key={value} value={value}>
                  {label}
                </SelectItem>
              ))}
            </SelectContent>
          </Select>
        </div>
        <GroupHeading id="cc-indent">Indent with</GroupHeading>
        <RadioGroup defaultValue="2" aria-labelledby="cc-indent">
          {INDENTS.map(({ value, label }) => (
            <div key={value} className="flex items-center gap-2">
              <RadioGroupItem value={value} id={`cc-indent-${value}`} />
              <Label htmlFor={`cc-indent-${value}`}>{label}</Label>
            </div>
          ))}
        </RadioGroup>
      </div>
      <div className="grid grid-cols-1 content-start gap-3">
        <Pane
          purpose="toolbar"
          className="flex min-h-control-sm items-center gap-2 px-2"
        >
          <Checkbox
            aria-label={selected.length > 0 ? "Select none" : "Select all"}
            checked={all ? true : selected.length > 0 ? "indeterminate" : false}
            onCheckedChange={() =>
              setSelected(
                selected.length > 0 ? [] : threads.map(({ id }) => id),
              )
            }
          />
          <span className="flex-1 font-medium text-ui">
            {selected.length > 0 ? `${selected.length} selected` : "Inbox"}
          </span>
          {selected.length > 0 && (
            <Button variant="outline" size="sm" onClick={archive}>
              <ArchiveIcon />
              Archive
            </Button>
          )}
        </Pane>
        <List purpose="listbox">
          {threads.length > 0 ? (
            <ul>
              {threads.map(({ id, subject }) => (
                <ListItem key={id} selected={selected.includes(id)} asChild>
                  <li className="flex min-h-row items-center gap-2 px-2">
                    <Checkbox
                      id={`cc-${id}`}
                      checked={selected.includes(id)}
                      onCheckedChange={(checked) =>
                        setSelected(
                          checked
                            ? [...selected, id]
                            : selected.filter((each) => each !== id),
                        )
                      }
                    />
                    <Label
                      htmlFor={`cc-${id}`}
                      className="block min-w-0 truncate font-normal"
                    >
                      {subject}
                    </Label>
                  </li>
                </ListItem>
              ))}
            </ul>
          ) : (
            <EmptyState title="Nothing in Inbox" className="py-4">
              New mail lands here. Archive what you have dealt with.
            </EmptyState>
          )}
        </List>
      </div>
    </div>
  );
}
```

On the left, the Settings demo's editor section. Its settings apply as they change, so the on-off ones are Switches; the language new files open as has too many options to show at once, so it is a Select; and the three ways to indent are worth seeing side by side, so they are a RadioGroup. On the right, Mail's conversations do nothing until **Archive**, so each row has a Checkbox. Tick one, and the box above them turns partly checked; press it to select none.

## Do and don't

**Do**

Use a Switch for a setting that applies immediately, with no Save button after it.

**Don't**

Put Switches in a form with a Save button: nobody can tell whether a flip already took effect.

**Do**

Show two to five options as a RadioGroup when people should compare them before choosing.

**Don't**

Hide three options in a Select to save a few lines: the choice costs a tap to open and the options cannot be read side by side.

## Which one

| The choice                                                                                                        | Takes effect           | Use                                                                                                                                                                                        |
| ----------------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| One setting, on or off                                                                                            | Immediately            | `Switch`                                                                                                                                                                                   |
| One yes or no in a form, or agreeing to terms                                                                     | On submit              | `Checkbox`                                                                                                                                                                                 |
| Any number of items from a set: filters, facets, a bulk selection                                                 | On apply or submit     | `Checkbox` list                                                                                                                                                                            |
| Exactly one of two to five, worth seeing together                                                                 | Either                 | `RadioGroup`                                                                                                                                                                               |
| Exactly one of many, or of options with long names                                                                | Either                 | `Select`                                                                                                                                                                                   |
| One of two or three modes of the tool in hand, in its toolbar                                                     | Immediately            | `SegmentedControl`                                                                                                                                                                         |
| One of a few icon toggles in a toolbar: an alignment                                                              | Immediately            | `ToolbarGroup` with `selection="single"`                                                                                                                                                   |
| Any number of tags or filters over a list, each on or off                                                         | Immediately            | `Toggle`s, side by side                                                                                                                                                                    |
| Exactly one of a list too long to scan, or one that grows with people's own data: a task, a person, a label       | Either                 | `FilterMenu`, behind a `SelectButton` that shows the pick                                                                                                                                  |
| Any number of a short set the app fixes, from a menu: a release's tags, a view's options                          | Immediately, each pick | `DropdownMenuCheckboxItem`s in a `DropdownMenu`                                                                                                                                            |
| Any number of a list too long to scan, or one that grows with people's own data: labels, assignees                | Immediately, each pick | `FilterMenu` with `selection="multiple"`                                                                                                                                                   |
| A number people know exactly: a count, a port, a font size                                                        | Either                 | `NumberInput`                                                                                                                                                                              |
| A value along a range, where the exact number matters less than the feel                                          | Either                 | `Slider`                                                                                                                                                                                   |
| None: a quantity read against its limit, seats taken or storage used                                              | Read only              | `Meter`, not a disabled `Slider`                                                                                                                                                           |
| A colour                                                                                                          | Either                 | `ColorPickerPopover`, with the app's palette as `swatches`                                                                                                                                 |
| One of a few panels of the same thing, each shown under the tabs in turn                                          | Immediately            | `Tabs`: they switch what is shown, not a value that is saved. Framed with their panels where the set is one block among others; `variant="pane"` where it switches everything a pane shows |
| One of a few ways to draw what is already on screen, with no panel of its own: a message as plain text or as HTML | Immediately            | `SegmentedControl`                                                                                                                                                                         |
| A block's drawing or its text as written: a diagram, a patch, rendered Markdown, an HTML page, a message, a tree  | Immediately            | `ContentSourceToggle` in its header, held down while the text shows                                                                                                                        |

A `SegmentedControl` sets how the tool works rather than a value it saves: the Binary inspector's typing mode, Overwrite or Insert, beside the commands it changes. A setting on a form or a settings screen, even one of two, is a RadioGroup. Icons that pick one of a few in a toolbar, an alignment, are a `ToolbarGroup` with `selection="single"`: short of room it keeps its row until it moves into the `⋯` whole, where a `SegmentedControl` first becomes a dropdown of its words ([Toolbars](/ui/guidelines/patterns/toolbars/index.md)).

A setting that changes one of a `SegmentedControl`'s choices, rather than being one of them, goes in a `SegmentedControlMenu` at the end of its run: the theme menu's Use AMOLED, which turns Dark into AMOLED, waits behind the ▾ after Auto, Light and Dark. Collapsed to a dropdown or moved into the `⋯`, the run keeps it, after its choices.

A `SplitButton` does the usual thing on its face and offers the others behind its arrow. Use it when one variant is what people want most of the time; when none is, the variants are a menu of their own.

A `Toggle` narrows what is on screen the moment it is pressed, and any number may be on: the Notes demo's tags above its list. Filters that wait for **Apply**, or a choice the app saves, are a Checkbox list.

The parent of a partly checked list is a Checkbox with `checked="indeterminate"`. A Switch has no indeterminate state and no "applies later": if the setting only takes effect once something else happens, it is not a Switch.

```tsx
import { PROFILE, TIME_ZONES } from "@orz/fixtures/account.ts";
import { Button } from "@orz/ui/components/button";
import { Checkbox } from "@orz/ui/components/checkbox";
import { Label } from "@orz/ui/components/label";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@orz/ui/components/select";
import { toast } from "sonner";

export function ProfileChoices() {
  return (
    <form
      className="grid max-w-md gap-5"
      onSubmit={(event) => {
        event.preventDefault();
        toast.success("Profile saved");
      }}
    >
      <div className="grid gap-2">
        <Label htmlFor="pc-time-zone">Time zone</Label>
        <Select defaultValue={PROFILE.timeZone}>
          <SelectTrigger id="pc-time-zone" className="w-full">
            <SelectValue />
          </SelectTrigger>
          <SelectContent>
            {TIME_ZONES.map(({ value, label }) => (
              <SelectItem key={value} value={value}>
                {label}
              </SelectItem>
            ))}
          </SelectContent>
        </Select>
      </div>
      <div className="flex items-center gap-2">
        <Checkbox id="pc-show-email" defaultChecked={PROFILE.showEmail} />
        <Label htmlFor="pc-show-email">Show my email on my profile</Label>
      </div>
      <Button type="submit" className="justify-self-end">
        Save profile
      </Button>
    </form>
  );
}
```

The Settings demo's profile form keeps its choices until **Save profile**, so its one yes or no is a Checkbox. Its time zone is one of thirteen, too many to lay out side by side, so it is a Select.

```tsx
import { TASKS, type Task } from "@orz/fixtures/tasks.ts";
import {
  FilterMenu,
  type FilterMenuSection,
  MatchedText,
  matchText,
} from "@orz/ui/components/filter-menu";
import { Label } from "@orz/ui/components/label";
import { SelectButton } from "@orz/ui/components/select";
import { useState } from "react";

interface TaskRow {
  id: string;
  label: string;
}

const row = (task: Task): TaskRow => ({
  id: String(task.id),
  label: `T-${task.id} ${task.title}`,
});

const SECTIONS: FilterMenuSection<TaskRow>[] = [
  {
    id: "open",
    label: "Open",
    rows: TASKS.filter((task) => task.status !== "closed").map(row),
  },
  {
    id: "closed",
    label: "Closed",
    rows: TASKS.filter((task) => task.status === "closed").map(row),
  },
];

export function DuplicateOf() {
  const [query, setQuery] = useState("");
  const [picked, setPicked] = useState<string>();
  const shown = SECTIONS.map((section) => ({
    ...section,
    rows: section.rows.filter((r) => matchText(r.label, query)),
  }));
  const label = SECTIONS.flatMap((section) => section.rows).find(
    (r) => r.id === picked,
  )?.label;
  return (
    <div className="grid max-w-md gap-3">
      <Label id="do-duplicate-of">Duplicate of</Label>
      <FilterMenu
        query={query}
        onQueryChange={setQuery}
        sections={shown}
        selectedId={picked}
        onSelect={(r) => setPicked(r.id)}
        renderRow={(r, state) => (
          <span className="truncate">
            <MatchedText text={r.label} query={state.query} />
          </span>
        )}
        placeholder="Filter by title or T-number…"
        inputLabel="Filter tasks"
        listLabel="Tasks"
        align="start"
        className="w-80"
      >
        <SelectButton
          aria-labelledby="do-duplicate-of"
          placeholder="Pick a task"
          className="w-full"
        >
          {label}
        </SelectButton>
      </FilterMenu>
    </div>
  );
}
```

A task is a duplicate of one of sixty others. A Select would make people scroll for it; people already know a word of its title or its number, so `FilterMenu` lets them type it. The trigger is a `SelectButton`, drawn as a Select's trigger, so the field reads as one: as tall as the fields beside it on touch, in their type rather than a button's heavier one, and sunk into the form under a style that sinks fields. It names the pick, and the menu closes on it. Use it once a list runs past what fits on one screen, or holds things people add themselves, whose number nobody can promise; a fixed set that fits, like the time zones above, stays a Select. A `FilterMenu` whose rows are places, a project switcher, goes rather than picks: each row is a link ([Navigation](/ui/guidelines/patterns/navigation/index.md#switching-between-many-places)). A long list that one of a menu's actions opens, moving a task to another project from its ⋯ menu, stays in that menu as a submenu that filters the same way ([Overlays](/ui/guidelines/patterns/overlays/index.md#long-submenus)).

A row with a few variants of its own, such as a theme's accents, keeps them under it: `getSubmenu` gives them, and `submenus="inline"` opens them in place from the row's ▾ or →, the group holding the pick open as the menu opens. They stay in the one list the arrow keys walk, and the row itself is still picked with one click. A row whose own list is long enough to want a filter box of its own opens it beside the menu instead, the default, with `submenuFilter`.

A pick that should leave the menu open calls `event.preventDefault()` in `onSelect`: one whose result comes later, where the menu closes once it has, or a row that only completes the query, as a reference picker's `Europe…` writes `Europe: `into the box and lists what is in it.

Rows that come from a server arrive after the menu opens and after each query. Until they do, pass `loading`: the list draws placeholder rows where they will stand, which wait as any skeleton does ([Loading, empty & error](/ui/guidelines/patterns/loading-empty-and-error/index.md)), and `empty` is kept for an answer with nothing in it, so "No matches" never shows for a question still being asked.

```tsx
import { TASK_LABELS, TASKS, type Task } from "@orz/fixtures/tasks.ts";
import { Badge } from "@orz/ui/components/badge";
import { Button } from "@orz/ui/components/button";
import {
  FilterMenu,
  MatchedText,
  matchText,
} from "@orz/ui/components/filter-menu";
import { List, ListItem, ListItemSelect } from "@orz/ui/components/list";
import { useSelection } from "@orz/ui/hooks/use-selection";
import { ChevronDownIcon, TagIcon } from "lucide-react";
import { useState } from "react";

const SHOWN = [60, 56, 53];

export function LabelsForSelected() {
  const [tasks, setTasks] = useState(() =>
    TASKS.filter((task) => SHOWN.includes(task.id)),
  );
  const selection = useSelection(
    tasks.map((task) => task.id),
    { defaultSelected: SHOWN },
  );
  const [query, setQuery] = useState("");
  const [order, setOrder] = useState<readonly string[]>(TASK_LABELS);
  // The tasks as the menu opened, which a label partly picked goes back to.
  const [opened, setOpened] = useState<readonly Task[]>(tasks);
  const editing = tasks.filter((task) => selection.isSelected(task.id));
  const count = (label: string) =>
    editing.filter((task) => task.labels.includes(label)).length;
  const selectedIds = TASK_LABELS.filter((l) => count(l) === editing.length);
  const mixedIds = TASK_LABELS.filter(
    (l) => count(l) > 0 && count(l) < editing.length,
  );
  // What the tasks have first, sorted as the menu opens and as the query
  // changes, never as a row is picked: no row moves under the pointer.
  const sort = () =>
    setOrder(
      TASK_LABELS.toSorted(
        (a, b) => Number(count(b) > 0) - Number(count(a) > 0),
      ),
    );
  const label = (task: Task, name: string, on: boolean) =>
    TASK_LABELS.filter((each) =>
      each === name ? on : task.labels.includes(each),
    );
  return (
    <div className="grid max-w-md gap-3">
      <FilterMenu
        selection="multiple"
        selectedIds={selectedIds}
        mixedIds={mixedIds}
        onOpenChange={(open) => {
          if (open) setOpened(tasks);
        }}
        query={query}
        onQueryChange={(next) => {
          setQuery(next);
          sort();
        }}
        sections={[
          {
            id: "labels",
            rows: order
              .filter((name) => matchText(name, query))
              .map((name) => ({ id: name })),
          },
        ]}
        onSelect={(row, event) =>
          setTasks((all) =>
            all.map((task) => {
              if (!selection.isSelected(task.id)) return task;
              const was = opened.find((each) => each.id === task.id);
              const on = event.mixed
                ? (was?.labels.includes(row.id) ?? false)
                : event.selected;
              return { ...task, labels: label(task, row.id, on) };
            }),
          )
        }
        renderRow={(row, state) => (
          <MatchedText text={row.id} query={state.query} />
        )}
        placeholder="Filter labels…"
        inputLabel="Filter labels"
        listLabel="Labels"
        className="w-56"
      >
        <Button
          variant="outline"
          className="justify-self-start"
          disabled={editing.length === 0}
        >
          <TagIcon />
          Labels
          <ChevronDownIcon className="text-muted-foreground" />
        </Button>
      </FilterMenu>
      <List purpose="collection" framed selection={selection}>
        <ul>
          {tasks.map((task) => (
            <ListItem key={task.id} value={task.id} asChild>
              <li className="flex min-h-row flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-ui">
                <ListItemSelect aria-label={`T-${task.id}`} />
                <span className="text-muted-foreground">T-{task.id}</span>
                <span className="min-w-0 flex-1 truncate">{task.title}</span>
                <span className="flex gap-1">
                  {TASK_LABELS.filter((name) => task.labels.includes(name)).map(
                    (name) => (
                      <Badge key={name} variant="outline">
                        {name}
                      </Badge>
                    ),
                  )}
                </span>
              </li>
            </ListItem>
          ))}
        </ul>
      </List>
    </div>
  );
}
```

**Labels** edits the labels on the tasks ticked below. With `selection="multiple"` each row is on or off by itself, and each pick takes effect at once while the menu stays open for the next. A label on only some of the tasks is partly picked, through `mixedIds`. A pick gives it to all of them, the next takes it off all of them, and the one after puts it back on just the ones it was on (`event.mixed`), so a slip costs two more picks rather than the tasks' own labels. Put what is picked first as the menu opens and as the query changes, never as a row is picked, so nothing moves under the pointer. A row that does something rather than being one of the choices, `Create “…”`, is an `action`: it takes no box.

A `DropdownMenuCheckboxItem` ticks with the same box, so a short set in a `DropdownMenu` and a long one in a `FilterMenu` read alike, and the list's length decides between them, not the look ([Overlays](/ui/guidelines/patterns/overlays/index.md#ticks-and-picks)).

```tsx
import { Frame } from "@orz/ui/components/frame";
import { Label } from "@orz/ui/components/label";
import { NumberInput } from "@orz/ui/components/number-input";
import { Pane } from "@orz/ui/components/pane";
import { useState } from "react";

export function FontSizeNumberInput() {
  const [fontSize, setFontSize] = useState(13);
  return (
    <div className="grid max-w-md gap-3">
      <div className="flex items-center justify-between gap-4">
        <Label htmlFor="fs-font-size">Font size</Label>
        <div className="flex items-center gap-2">
          <NumberInput
            id="fs-font-size"
            min={11}
            max={20}
            value={fontSize}
            onValueChange={setFontSize}
            aria-describedby="fs-font-size-unit"
            className="w-20"
          />
          <span
            id="fs-font-size-unit"
            className="text-muted-foreground text-ui"
          >
            px
          </span>
        </div>
      </div>
      <Frame inset asChild>
        <Pane purpose="document">
          <pre
            className="overflow-x-auto p-3 font-mono leading-[1.6]"
            style={{ fontSize }}
          >
            <code>{"function greet(name) {"}</code>
          </pre>
        </Pane>
      </Frame>
    </div>
  );
}
```

People know their font size by its number, and pick it a pixel at a time, so the Settings demo's is a `NumberInput`: type it, or step it with the arrows beside it or the arrow keys, and the line of code under it follows each step. A Slider of a few stops would hide the number under a feel nobody asked for. Put the unit in a word after the field, as here, not in the label.

A Slider is for what is judged by eye or by ear rather than read off: the place in a recording, a volume. In the pull request demo's Checks, press **Recording**: its seek bar is a Slider. A screen reader still reads out the number under it, so where that number is not what a listener would say, seconds or a share of one, `valueText` gives the words: this seek bar says its place against the recording's length, and a volume says a percentage.

```tsx
import { TASK_LABELS } from "@orz/fixtures/tasks.ts";
import { ColorPickerPopover } from "@orz/ui/components/color-picker";
import { List, ListItem } from "@orz/ui/components/list";
import { useState } from "react";

const PALETTE = [
  "#6b7280",
  "#ef4444",
  "#f97316",
  "#eab308",
  "#22c55e",
  "#14b8a6",
  "#0ea5e9",
  "#3b82f6",
  "#8b5cf6",
  "#ec4899",
];

export function LabelColours() {
  const [colours, setColours] = useState<Record<string, string>>(() =>
    Object.fromEntries(
      TASK_LABELS.map((label, i) => [
        label,
        PALETTE[(i * 3 + 1) % PALETTE.length] ?? "#6b7280",
      ]),
    ),
  );
  return (
    <List purpose="collection" className="max-w-xs">
      <ul>
        {TASK_LABELS.map((label) => (
          <ListItem key={label} asChild>
            <li className="flex min-h-row items-center gap-2 px-3 py-1.5">
              <span className="flex-1 text-ui">{label}</span>
              <ColorPickerPopover
                value={colours[label] ?? "#6b7280"}
                onValueChange={(value) =>
                  setColours((all) => ({ ...all, [label]: value }))
                }
                format="hex"
                alpha={false}
                swatches={PALETTE}
                align="end"
                aria-label={`Colour of ${label}`}
              />
            </li>
          </ListItem>
        ))}
      </ul>
    </List>
  );
}
```

A label's colour only tells it apart from the others, so the app's palette rides along as swatches and most picks are one tap; the area and sliders above them are there for a colour of one's own. Pass `format="hex"` and `alpha={false}` when the colour is stored as a plain hex. Open the full `ColorPicker`, without the popover, only where colour is the work itself, such as a theme editor.

```tsx
import { CI_RUN } from "@orz/fixtures/ci-run.ts";
import { PULL_REQUEST } from "@orz/fixtures/pull-request.ts";
import { FrameBar } from "@orz/ui/components/frame";
import { InlineCode } from "@orz/ui/components/inline-code";
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@orz/ui/components/tabs";

const comments = PULL_REQUEST.timeline.filter(
  (event) => event.kind === "comment",
);
const pushes = PULL_REQUEST.timeline.filter((event) => event.kind === "push");

export function PullRequestTabs() {
  return (
    <Tabs variant="framed" defaultValue="conversation" className="min-w-0">
      <FrameBar>
        <TabsList>
          <TabsTrigger value="conversation">Conversation</TabsTrigger>
          <TabsTrigger value="commits">Commits</TabsTrigger>
          <TabsTrigger value="checks">Checks</TabsTrigger>
        </TabsList>
      </FrameBar>
      <TabsContent value="conversation" className="p-3">
        <p className="text-ui">
          {comments.length} comments on “{PULL_REQUEST.title}”.
        </p>
      </TabsContent>
      <TabsContent value="commits" className="p-3">
        <ul className="grid gap-1 text-ui">
          {pushes.map((push) => (
            <li key={push.commit}>
              <InlineCode>{push.commit}</InlineCode> pushed by {push.author}
            </li>
          ))}
        </ul>
      </TabsContent>
      <TabsContent value="checks" className="p-3">
        <ul className="grid gap-1 text-ui">
          {CI_RUN.jobs.map((job) => (
            <li key={job.id}>
              {CI_RUN.workflow} / {job.name}: {job.status}
            </li>
          ))}
        </ul>
      </TabsContent>
    </Tabs>
  );
}
```

The tabs above show a pull request's conversation, commits and checks in turn, in a box on a page about something else. Nothing is saved by picking one. Tabs are for switching panels: each tab has one. A set that is one block among others in a surface's flow, as this one is, is drawn with its panels as one `Frame` by `Tabs variant="framed"`: the strip on the frame's lid, its `FrameBar`, beside whatever else names or acts on the set, and the current tab cut out of the strip into its panel. Where each would be a page of its own, with an address a reader sends to someone and Back leaves, as the same parts of a pull request are in the [Pull request demo](/ui/demos/pull-request/index.md), they are places: a `TabNav` of links ([Navigation](/ui/guidelines/patterns/navigation/index.md)). A switch with no panel under it, one that redraws what is already on screen, is a `SegmentedControl`. A block's text as written is not one of its views in this sense: the drawing and the text are one thing read two ways, so the block's header holds **Source**, a toggle held down while the text shows, rather than a pair of tabs.

Tabs that switch everything a pane shows below its header, as a release's overview, log and diff do in the [Releases demo](/ui/demos/releases/index.md), are the pane's own rather than a block in it: `Tabs variant="pane"` runs the strip across the pane's row, its rule meeting the pane's sides, and the current panel fills the rest of the pane and scrolls on its own. Framed, the set would draw a second edge inside the pane's and take a gutter from every panel.

## On each platform

### Desktop & pointer

- The label is part of the hit area: pair every control with a `Label` through `htmlFor`, so a click on the words toggles it.
- Space toggles a Switch or Checkbox; the arrow keys move within a RadioGroup, and Tab leaves it.
- Rows stay compact. A settings list reads as a column of labels with the controls on one edge.

### Touch

- The controls take their touch sizes on a coarse pointer by themselves; there is no prop to set. **Touch**, above an example, previews them.
- In a settings list, put the label on the leading edge and the Switch on the trailing edge, as the phone's own settings do.
- A Select opens a list the width of the trigger: keep option names short enough to read in it.

## In the demos

- [Settings](/ui/demos/settings/index.md): Editor's Switches apply as they flip, with no Save button, and its preview follows, as it follows each step of the font size NumberInput. The language is a Select of many and the indent a RadioGroup of three. Profile's Checkbox waits for Save profile.
- [Admin](/ui/demos/admin/index.md): Seats and storage are Meters, read against their limit and set nowhere here; storage nearly full turns the warning colour. In Settings, Require two-step sign-in is a Switch that applies as it flips.
- [Tasks](/ui/demos/tasks/index.md): Each filter is a menu you can search, picking one status, person or label, and it applies at once. List and Board is a SegmentedControl: two ways to show the same tasks, switched in place. Rows are picked with Checkboxes for the bulk bar, and New task picks its assignee and label from Selects.
