# Listbox

A list of options in the page to pick one or several, without a popup.

A list of options laid in the page to pick one or several, without a popup. The select's list laid in the page: option rows under one gliding highlight, in a box with the popup's padding and radius but the field's hairline instead of a lift. Single choice (a click replaces) or multiple (a click adds or removes); a check marks every chosen row. The list holds focus and the arrow keys move the highlight, which glides under the pointer and the keyboard alike. Behaviour, focus and ARIA come from the Zag listbox machine, through Ark UI.

Kind: component · Category: Inputs · Status: beta · Targets: React, Vue, Svelte · Behaviour: Zag `listbox` machine, through Ark UI

## Add

```bash
npx fndn add listbox
```

It writes the folder `listbox/` into the project's ui folder (`index.ts`, `listbox.tsx`, `Listbox.vue`, `Listbox.svelte`, `listbox.recipe.ts`). First time: [Installation](/installation.md).

## Usage

```tsx
import { Listbox } from "@/components/ui/listbox";
```

```vue
import { Listbox } from "@/components/ui/listbox";
```

```svelte
import { Listbox } from "$lib/components/ui/listbox";
```

## Parts

In the DOM the root carries `data-slot="listbox"` and each part `data-slot="listbox-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `listbox` |  |  |
| `label` | `label` | `listbox-label` | optional | Names the list (aria-labelledby) |
| `content` | `div` | `listbox-content` |  | role=listbox; the tab stop (rows are reached through aria-activedescendant). card: surface, 4px padding, card radius, hairline, scrolls inside itself past 360px. flush: no surface, no hairline, no padding, no height cap (its pane scrolls), rows edge to edge. Both: the field's accent ring when focused from the keyboard. At least 120px wide, then as wide as its longest option (or the width given). aria-multiselectable in multiple mode. size sm: 26px rows. |
| `highlight` | `span` | `listbox-highlight` |  | Shared gliding highlight layer (`glideLayer` of `lib/glide.ts`); glides under the pointer and the arrow keys alike. Shown while the list is hovered or holds focus; fades out when neither. 4px in from the box's edges in card, edge to edge in flush. |
| `item` | `div` | `listbox-item` | repeats | role=option; data-state=checked\|unchecked, aria-selected, data-disabled from the engine. data-highlighted is written by the adapter: the engine's highlighted value, while the list is hovered or holds focus (the engine alone marks it only under keyboard focus, so the pointer would never move the highlight). A mouse move over a row makes it the highlighted value unless the last input was a key. The shared option row (`lib/option.ts`). |
| `item-icon` | `span` | `listbox-item-icon` | optional | Leading icon of an option (14px glyph, ink-3; aria-hidden): what the choice is at a glance, e.g. the channel or the provider. React: a node (a Phosphor icon with data-slot="icon" weight="bold"); Vue and Svelte: an icon component, drawn bold |
| `item-text` | `span` | `listbox-item-text` |  | Shown whole: wraps, never cut. Followed by a description, it keeps up to 70% of the row |
| `item-description` | `span` | `listbox-item-description` | optional | One line after the label (12px, ink-2) that says what the choice means: an address, a cost, a consequence. The one part that is cut: it gives way to the label and carries a title with its full text It sits on the label's first line (shared baseline), also when the label wraps. |
| `item-meta` | `span` | `listbox-item-meta` | optional | At the row's end, before the check: a note or a count (2xs, ink-2, tabular figures), or a status letter in its tone (metaTone: 12px, medium; M modified orange, A added green, D deleted red). Never wraps. |
| `item-indicator` | `span` | `listbox-item-indicator` |  | Check on every chosen row; keeps its space on other rows |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `{ value: string; label: string; description: string? (one line after the label, cut with a title); icon: icon? (React: a node; Vue / Svelte: a component); meta: string? (at the row's end: a note, a count, a status letter); disabled?: boolean; metaTone: neutral\|accent\|green\|orange\|red? (a status letter in its tone: M orange, A green, D red) }[]` |  | Options in order. Strings are accepted as value = label. An icon and a description help when the options are things the user tells apart by kind or by detail (alert channels, providers, plans); keep plain labels for short lists of names. |
| `value` | `array` |  | Bindable (React: `defaultValue` and `onValueChange`; Vue: `v-model:value`; Svelte: `bind:value`). The chosen values (one at most in single mode). |
| `selectionMode` | `"single" \| "multiple"` | `"single"` | single: a click or Enter replaces the choice. multiple: a click or Enter adds or removes the row. |
| `label` | `string` |  | Visible label; otherwise pass aria-label. |
| `size` | `"xs" \| "sm" \| "md" \| "lg"` | `"md"` | Row height, the one control scale: xs 24 · sm 28 (dense lists: an editor's change list or explorer; 12px text) · md 32 · lg 36 (13px). Dimensions only. |
| `variant` | `"card" \| "flush"` | `"card"` | card: the popup's box laid in the page (surface, hairline, 4px padding). flush: no box, the list is part of its pane, like an editor's change list or explorer; rows run edge to edge and the pane does the scrolling. The keyboard focus ring shows in both. |
| `disabled` | `boolean` | `false` |  |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `valueChange` | (value: string[]) |

## States

`focus-visible`, `highlighted`, `selected`, `disabled`

## Keyboard and accessibility

Role: listbox.

Keyboard:

- Tab focuses the list (one tab stop); the highlight shows on the chosen row, else the first
- ArrowDown / ArrowUp move the highlight; Home / End jump to the first and last option
- Typing jumps to the matching option (type-ahead)
- Enter or Space chooses the highlighted option (multiple: adds or removes it)
- Tab moves on

Notes:

- Give it a visible label or an aria-label.
- Focus stays on the list; the highlighted option is announced through aria-activedescendant, chosen ones through aria-selected.
- Every option is readable in full: past the list's width it wraps. A description is part of the option's text (read with it); cut on screen, it keeps its full text in a title.
- The icon is decoration (aria-hidden): the label alone must name the choice.

## Motion

- highlight: one layer glides between options over duration.move, easing.out-strong, under the pointer and the arrow keys alike; it fades in and out over duration.base
- rows: a pressed option darkens to color.hover-2 over duration.fast; choosing is instant
- focus ring: box-shadow over duration.base

## Tokens

`color.surface`, `color.hover`, `color.hover-2`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.accent`, `color.accent-tint`, `shadow.hairline`, `radius.card`, `radius.chip`, `text.2xs`, `text.xs`, `text.sm`, `text.md`, `duration.fast`, `duration.base`, `duration.move`, `easing.out-strong`, `color.green`, `color.orange`, `color.red`, `color.accent-ink`

## Examples

### Deploy region

React · `region.tsx`

```tsx
import { Listbox } from "@/components/ui/listbox";

/* every option stays in view; meta on the right, a disabled option says why */
const regions = [
  { value: "iad1", label: "Washington, D.C. (iad1)", meta: "18 ms" },
  { value: "fra1", label: "Frankfurt (fra1)", meta: "96 ms" },
  { value: "gru1", label: "São Paulo (gru1)", meta: "Business plan", disabled: true },
];

export default function Region() {
  return <Listbox items={regions} label="Region" defaultValue={["iad1"]} style={{ width: 280 }} />;
}
```

Vue · `region.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox } from "@/components/ui/listbox";

/* every option stays in view; meta on the right, a disabled option says why */
const regions = [
  { value: "iad1", label: "Washington, D.C. (iad1)", meta: "18 ms" },
  { value: "fra1", label: "Frankfurt (fra1)", meta: "96 ms" },
  { value: "gru1", label: "São Paulo (gru1)", meta: "Business plan", disabled: true },
];

const region = ref(["iad1"]);
</script>

<template>
  <Listbox :items="regions" v-model:value="region" label="Region" style="width: 280px" />
</template>
```

Svelte · `region.svelte`

```svelte
<script lang="ts">
  import { Listbox } from "$lib/components/ui/listbox";

  /* every option stays in view; meta on the right, a disabled option says why */
  const regions = [
    { value: "iad1", label: "Washington, D.C. (iad1)", meta: "18 ms" },
    { value: "fra1", label: "Frankfurt (fra1)", meta: "96 ms" },
    { value: "gru1", label: "São Paulo (gru1)", meta: "Business plan", disabled: true },
  ];

  let region = $state(["iad1"]);
</script>

<Listbox items={regions} bind:value={region} label="Region" style="width: 280px" />
```

### Email notifications

React · `notifications.tsx`

```tsx
import { Listbox } from "@/components/ui/listbox";

const events = [
  { value: "deploy-failed", label: "A deploy fails" },
  { value: "deploy-ready", label: "A production deploy is ready" },
  { value: "review", label: "Someone requests my review" },
  { value: "invoice", label: "An invoice is paid" },
  { value: "seats", label: "The workspace runs out of seats" },
];

export default function Notifications() {
  return (
    <Listbox items={events} label="Email me when" selectionMode="multiple" defaultValue={["deploy-failed", "review"]} style={{ width: 280 }} />
  );
}
```

Vue · `notifications.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox } from "@/components/ui/listbox";

const events = [
  { value: "deploy-failed", label: "A deploy fails" },
  { value: "deploy-ready", label: "A production deploy is ready" },
  { value: "review", label: "Someone requests my review" },
  { value: "invoice", label: "An invoice is paid" },
  { value: "seats", label: "The workspace runs out of seats" },
];

const picked = ref(["deploy-failed", "review"]);
</script>

<template>
  <Listbox :items="events" v-model:value="picked" label="Email me when" selection-mode="multiple" style="width: 280px" />
</template>
```

Svelte · `notifications.svelte`

```svelte
<script lang="ts">
  import { Listbox } from "$lib/components/ui/listbox";

  const events = [
    { value: "deploy-failed", label: "A deploy fails" },
    { value: "deploy-ready", label: "A production deploy is ready" },
    { value: "review", label: "Someone requests my review" },
    { value: "invoice", label: "An invoice is paid" },
    { value: "seats", label: "The workspace runs out of seats" },
  ];

  let picked = $state(["deploy-failed", "review"]);
</script>

<Listbox items={events} bind:value={picked} label="Email me when" selectionMode="multiple" style="width: 280px" />
```

### Where to send deploy alerts

React · `alert-channels.tsx`

```tsx
import { Bell, DeviceMobile, EnvelopeSimple, Link } from "@phosphor-icons/react";
import { Listbox } from "@/components/ui/listbox";

/* an icon says what kind of channel, a one-line description where it goes; a long one is cut, with a title */
const channels = [
  { value: "email", label: "Email", description: "maya@northwind.example and 3 teammates", icon: <EnvelopeSimple data-slot="icon" weight="bold" /> },
  { value: "sms", label: "Text message", description: "+1 (555) 014-2290", icon: <DeviceMobile data-slot="icon" weight="bold" /> },
  { value: "webhook", label: "Webhook", description: "POST https://hooks.northwind.example/deploys/web-app", icon: <Link data-slot="icon" weight="bold" /> },
  { value: "inbox", label: "Workspace inbox", description: "No email, shown when you sign in", icon: <Bell data-slot="icon" weight="bold" /> },
];

export default function AlertChannels() {
  return (
    <Listbox items={channels} label="Send failed deploy alerts to" selectionMode="multiple" defaultValue={["email", "webhook"]} style={{ width: 320 }} />
  );
}
```

Vue · `alert-channels.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PhBell, PhDeviceMobile, PhEnvelopeSimple, PhLink } from "@phosphor-icons/vue";
import { Listbox } from "@/components/ui/listbox";

/* an icon says what kind of channel, a one-line description where it goes; a long one is cut, with a title */
const channels = [
  { value: "email", label: "Email", description: "maya@northwind.example and 3 teammates", icon: PhEnvelopeSimple },
  { value: "sms", label: "Text message", description: "+1 (555) 014-2290", icon: PhDeviceMobile },
  { value: "webhook", label: "Webhook", description: "POST https://hooks.northwind.example/deploys/web-app", icon: PhLink },
  { value: "inbox", label: "Workspace inbox", description: "No email, shown when you sign in", icon: PhBell },
];

const selected = ref(["email", "webhook"]);
</script>

<template>
  <Listbox :items="channels" v-model:value="selected" label="Send failed deploy alerts to" selection-mode="multiple" style="width: 320px" />
</template>
```

Svelte · `alert-channels.svelte`

```svelte
<script lang="ts">
  import Bell from "phosphor-svelte/lib/BellIcon";
  import DeviceMobile from "phosphor-svelte/lib/DeviceMobileIcon";
  import EnvelopeSimple from "phosphor-svelte/lib/EnvelopeSimpleIcon";
  import Link from "phosphor-svelte/lib/LinkIcon";
  import { Listbox } from "$lib/components/ui/listbox";

  /* an icon says what kind of channel, a one-line description where it goes; a long one is cut, with a title */
  const channels = [
    { value: "email", label: "Email", description: "maya@northwind.example and 3 teammates", icon: EnvelopeSimple },
    { value: "sms", label: "Text message", description: "+1 (555) 014-2290", icon: DeviceMobile },
    { value: "webhook", label: "Webhook", description: "POST https://hooks.northwind.example/deploys/web-app", icon: Link },
    { value: "inbox", label: "Workspace inbox", description: "No email, shown when you sign in", icon: Bell },
  ];

  let selected = $state(["email", "webhook"]);
</script>

<Listbox items={channels} bind:value={selected} label="Send failed deploy alerts to" selectionMode="multiple" style="width: 320px" />
```

### Group by, in a side panel

React · `group-by.tsx`

```tsx
import { Listbox } from "@/components/ui/listbox";

/* sm: the dense size for side panels and popovers */
export default function GroupBy() {
  return (
    <Listbox items={["Project", "Environment", "Author", "No grouping"]} size="sm" label="Group deploys by" defaultValue={["Environment"]} style={{ width: 180 }} />
  );
}
```

Vue · `group-by.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox } from "@/components/ui/listbox";

const group = ref(["Environment"]);
</script>

<!-- sm: the dense size for side panels and popovers -->
<template>
  <Listbox :items="['Project', 'Environment', 'Author', 'No grouping']" v-model:value="group" size="sm" label="Group deploys by" style="width: 180px" />
</template>
```

Svelte · `group-by.svelte`

```svelte
<script lang="ts">
  import { Listbox } from "$lib/components/ui/listbox";

  let group = $state(["Environment"]);
</script>

<!-- sm: the dense size for side panels and popovers -->
<Listbox items={["Project", "Environment", "Author", "No grouping"]} bind:value={group} size="sm" label="Group deploys by" style="width: 180px" />
```

### Projects to export

React · `export-projects.tsx`

```tsx
import { useState } from "react";
import { Listbox } from "@/components/ui/listbox";

const projects = ["web-app", "billing-api", "mobile", "docs-site", "data-pipeline"];

export default function ExportProjects() {
  const [picked, setPicked] = useState<string[]>(["web-app", "billing-api"]);
  return (
    <div className="flex flex-col gap-2" style={{ width: 240 }}>
      <Listbox items={projects} label="Projects to export" selectionMode="multiple" value={picked} onValueChange={setPicked} />
      <span className="text-sm text-ink-2">{picked.length ? `${picked.length} of ${projects.length} projects` : "Pick at least one project."}</span>
    </div>
  );
}
```

Vue · `export-projects.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox } from "@/components/ui/listbox";

const projects = ["web-app", "billing-api", "mobile", "docs-site", "data-pipeline"];
const picked = ref<string[]>(["web-app", "billing-api"]);
</script>

<template>
  <div class="flex flex-col gap-2" style="width: 240px">
    <Listbox :items="projects" v-model:value="picked" label="Projects to export" selection-mode="multiple" />
    <span class="text-sm text-ink-2">{{ picked.length ? `${picked.length} of ${projects.length} projects` : "Pick at least one project." }}</span>
  </div>
</template>
```

Svelte · `export-projects.svelte`

```svelte
<script lang="ts">
  import { Listbox } from "$lib/components/ui/listbox";

  const projects = ["web-app", "billing-api", "mobile", "docs-site", "data-pipeline"];
  let picked = $state<string[]>(["web-app", "billing-api"]);
</script>

<div class="flex flex-col gap-2" style="width: 240px">
  <Listbox items={projects} bind:value={picked} label="Projects to export" selectionMode="multiple" />
  <span class="text-sm text-ink-2">{picked.length ? `${picked.length} of ${projects.length} projects` : "Pick at least one project."}</span>
</div>
```

### Changed files, with status letters

React · `changed-files.tsx`

```tsx
import { Listbox, type ListboxItem } from "@/components/ui/listbox";

/* an editor's change list: xs rows, the folder dimmed after the name, a status letter at the end in
 * its tone (M modified, A added, D deleted) */
const changes: ListboxItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
  { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
  { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
  { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
];

export default function ChangedFiles() {
  return <Listbox items={changes} size="xs" aria-label="Changes" defaultValue={["src/middleware/rate-limit.ts"]} style={{ width: 280 }} />;
}
```

Vue · `changed-files.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox, type ListboxItem } from "@/components/ui/listbox";

/* an editor's change list: xs rows, the folder dimmed after the name, a status letter at the end in
 * its tone (M modified, A added, D deleted) */
const changes: ListboxItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
  { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
  { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
  { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
];

const selected = ref(["src/middleware/rate-limit.ts"]);
</script>

<template>
  <Listbox :items="changes" v-model:value="selected" size="xs" aria-label="Changes" style="width: 280px" />
</template>
```

Svelte · `changed-files.svelte`

```svelte
<script lang="ts">
  import { Listbox, type ListboxItem } from "$lib/components/ui/listbox";

  /* an editor's change list: xs rows, the folder dimmed after the name, a status letter at the end in
   * its tone (M modified, A added, D deleted) */
  const changes: ListboxItem[] = [
    { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
    { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
    { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
    { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
  ];

  let selected = $state(["src/middleware/rate-limit.ts"]);
</script>

<Listbox items={changes} bind:value={selected} size="xs" aria-label="Changes" style="width: 280px" />
```

### Flush, in a source-control pane

React · `source-control.tsx`

```tsx
import { Listbox, type ListboxItem } from "@/components/ui/listbox";

/* flush: the change list of an editor's source-control pane. No card: the rows belong to the pane,
 * run edge to edge, and the pane's heading sits on the same inset as their text */
const changes: ListboxItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
  { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
  { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
  { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
];

export default function SourceControl() {
  return (
    <section className="flex w-[280px] flex-col gap-1 rounded-card bg-inset p-1">
      <h3 className="m-0 px-2 pt-1 text-2xs font-medium uppercase tracking-wide text-ink-2">Changes</h3>
      <Listbox items={changes} variant="flush" size="xs" aria-label="Changes" defaultValue={["src/middleware/rate-limit.ts"]} />
    </section>
  );
}
```

Vue · `source-control.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Listbox, type ListboxItem } from "@/components/ui/listbox";

/* flush: the change list of an editor's source-control pane. No card: the rows belong to the pane,
 * run edge to edge, and the pane's heading sits on the same inset as their text */
const changes: ListboxItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
  { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
  { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
  { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
];

const selected = ref(["src/middleware/rate-limit.ts"]);
</script>

<template>
  <section class="flex w-[280px] flex-col gap-1 rounded-card bg-inset p-1">
    <h3 class="m-0 px-2 pt-1 text-2xs font-medium uppercase tracking-wide text-ink-2">Changes</h3>
    <Listbox :items="changes" v-model:value="selected" variant="flush" size="xs" aria-label="Changes" />
  </section>
</template>
```

Svelte · `source-control.svelte`

```svelte
<script lang="ts">
  import { Listbox, type ListboxItem } from "$lib/components/ui/listbox";

  /* flush: the change list of an editor's source-control pane. No card: the rows belong to the pane,
   * run edge to edge, and the pane's heading sits on the same inset as their text */
  const changes: ListboxItem[] = [
    { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", description: "src/middleware", meta: "M", metaTone: "orange" },
    { value: "src/webhooks/retry-policy.ts", label: "retry-policy.ts", description: "src/webhooks", meta: "A", metaTone: "green" },
    { value: "src/webhooks/legacy-queue.ts", label: "legacy-queue.ts", description: "src/webhooks", meta: "D", metaTone: "red" },
    { value: "package.json", label: "package.json", meta: "M", metaTone: "orange" },
  ];

  let selected = $state(["src/middleware/rate-limit.ts"]);
</script>

<section class="flex w-[280px] flex-col gap-1 rounded-card bg-inset p-1">
  <h3 class="m-0 px-2 pt-1 text-2xs font-medium uppercase tracking-wide text-ink-2">Changes</h3>
  <Listbox items={changes} bind:value={selected} variant="flush" size="xs" aria-label="Changes" />
</section>
```

## Recipe

`listbox.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";
import { option } from "../lib/option";
import { glideLayer } from "../lib/glide";

/* listbox — the select's list, laid in the page: a box of option rows under one gliding
 * highlight, single or multiple choice. Behaviour comes from the Zag listbox machine (role=listbox
 * on the content, which takes focus; aria-activedescendant; data-highlighted, data-state on rows).
 *
 * The box is the popup's (surface, 4px padding, card radius, rows concentric inside it) without
 * the popup's lift and motion: it sits in the page, so it takes the field's hairline instead of
 * the raised shadow, and the field's accent ring when focused from the keyboard. Rows compose the
 * shared option row; the one highlight is the shared glide. It scrolls inside itself past 360px.
 *
 * flush (variant): no card. A list that is part of its pane (an editor's change list, an
 * explorer): no surface, no hairline, no padding, no height cap (the pane scrolls); the rows and
 * their highlight run edge to edge of the list, so their text lines up with the pane's own 8px
 * inset. The keyboard focus ring stays: it is the only sign the list holds focus. */

const row = option();
const DIR = "[unicode-bidi:plaintext] [text-align:match-parent]";

export const listbox = tv({
  slots: {
    base: "inline-flex flex-col gap-1.5 min-w-0 max-w-full",
    label: "text-sm font-medium text-ink",
    content: [
      "relative flex flex-col min-w-[120px] overflow-y-auto",
      "rounded-card text-ink outline-none",
      /* the content holds focus (the rows are reached through aria-activedescendant): the field's
       * accent ring when a key moved focus here; nothing after a press on a row (the engine focuses
       * the list from its mousedown, which Chromium counts as :focus-visible). data-fndn-focus-input
       * is set by trackModality. */
      "[:root[data-fndn-focus-input=keyboard]_&]:focus:[box-shadow:0_0_0_1px_var(--fndn-accent),0_0_0_4px_var(--fndn-accent-tint)]",
      "data-disabled:opacity-50 data-disabled:pointer-events-none",
      "motion-shadow-base",
    ],
    /* the list's cursor: on the row the adapter marks data-highlighted while the list is hovered or
     * holds focus; it fades out when neither */
    highlight: glideLayer,
    item: [row.base(), "shrink-0"],
    /* optional leading icon (14px, ink-3) and one-line description after the label: the shared
     * option row's. The description is the one part that is cut (the label keeps 70% of the row,
     * and wraps), so the adapter gives it a title with its full text. */
    itemIcon: row.icon(),
    itemText: row.text(),
    itemDescription: row.description(),
    /* at the row's end, before the check: a note, a count or a status letter (metaTone) */
    itemMeta: [row.meta(), DIR, "tabular-nums"],
    itemIndicator: row.indicator(),
  },
  variants: {
    /* the one control scale: xs 24 · sm 28 · md 32 · lg 36 rows (dimensions only). xs and sm are
     * the dense lists of editors (a source-control change list, an explorer); 12px text there */
    size: {
      xs: { content: "[--option-height:24px]", item: "py-1 text-xs" },
      sm: { content: "[--option-height:28px]", item: "text-xs" },
      md: { content: "[--option-height:32px]" },
      lg: { content: "[--option-height:36px]", item: "text-sm" },
    },
    /* the meta's tone: a status letter (M modified, A added, D deleted) in its colour; neutral is
     * the quiet ink-2 note or count */
    metaTone: {
      neutral: {},
      accent: { itemMeta: "text-xs font-medium text-accent-ink" },
      green: { itemMeta: "text-xs font-medium text-green" },
      orange: { itemMeta: "text-xs font-medium text-orange" },
      red: { itemMeta: "text-xs font-medium text-red" },
    },
    /* card: the popup's box laid in the page. flush: no box, part of its pane */
    variant: {
      card: { content: "max-h-[360px] p-1 bg-surface shadow-hairline", highlight: "inset-x-1" },
      flush: { content: "p-0 bg-transparent shadow-none" },
    },
  },
  defaultVariants: { size: "md", metaTone: "neutral", variant: "card" },
});

export type ListboxRecipeProps = VariantProps<typeof listbox>;
```
