Todae

Todae

OptionList

role="listbox" with aria-activedescendant. An option's title is a string, and OptionList.OptionDetail can add a line under it. Keyboard is Arrow, Home, End, Enter, and Space, and typing a letter moves to the next option whose title starts with it. Escape is not handled so it can close a parent Popover.

On this page

Single value is string | null. Multiple value is string[]. Selected options stay font-weight: 400 and use an accent-soft row fill (color.bg.selected, 12% accent). Highlighted selected is 20% (color.accent.soft-strong). Rows are 2px apart. Hover is gated with @media (hover: hover).

import { OptionList } from '@tounsoo/todae';
import { useState } from 'react';

export default function OptionListSingle() {
  const [value, setValue] = useState<string | null>('pear');
  return (
    <OptionList.Root value={value} onValueChange={setValue} aria-label="Fruit">
      <OptionList.Option value="apple">Apple</OptionList.Option>
      <OptionList.Option value="pear">Pear</OptionList.Option>
      <OptionList.Option value="plum">Plum</OptionList.Option>
    </OptionList.Root>
  );
}
Apple
Pear
Plum

With selectionMode="multiple", every row keeps a check gutter. Selected fills the box and draws the check glyph.

import { OptionList } from '@tounsoo/todae';
import { useState } from 'react';

export default function OptionListMultiple() {
  const [value, setValue] = useState<string[]>(['apple']);
  return (
    <OptionList.Root selectionMode="multiple" value={value} onValueChange={setValue} aria-label="Fruit">
      <OptionList.Option value="apple">Apple</OptionList.Option>
      <OptionList.Option value="pear">Pear</OptionList.Option>
      <OptionList.Option value="plum">Plum</OptionList.Option>
    </OptionList.Root>
  );
}
Apple
Pear
Plum

Options are OptionList.Option parts inside OptionList.Root.

Detail

OptionList.OptionDetail is a second line under the title. The option's name is the title, then the detail, so it holds every word the option shows and a speech user can say what they see (WCAG 2.5.3, Label in Name). Typing and the arrow keys still use the title.

<OptionList.Option value="apple">
  Apple
  <OptionList.OptionDetail>Crisp and sweet</OptionList.OptionDetail>
</OptionList.Option>
import { OptionList } from '@tounsoo/todae';
import { useState } from 'react';

const ROWS = [
  { value: 'apple', title: 'Apple', detail: 'Crisp and sweet' },
  { value: 'pear', title: 'Pear', detail: 'Soft when ripe' },
  { value: 'plum', title: 'Plum', detail: 'Tart and juicy' },
] as const;

export default function OptionListDetail() {
  const [value, setValue] = useState<string | null>('pear');
  return (
    <OptionList.Root value={value} onValueChange={setValue} aria-label="Fruit">
      {ROWS.map((row) => (
        <OptionList.Option key={row.value} value={row.value}>
          {row.title}
          <OptionList.OptionDetail>{row.detail}</OptionList.OptionDetail>
        </OptionList.Option>
      ))}
    </OptionList.Root>
  );
}
Apple Crisp and sweet
Pear Soft when ripe
Plum Tart and juicy

A combobox can pass id, activeValue, onActiveValueChange, and tabIndex={-1} so the input owns focus and aria-activedescendant. Uncontrolled lists keep tabIndex={0}.

Icons

A selected option shows the check glyph: Todae's check mark, unless a GlyphsProvider sets one. In a multiple list it sits inside the box. The check shows at once as an option is picked. A brand can grow it in with option.check.motion.duration (0ms by default) and option.check.motion.easing, as Checkbox's check grows; it still goes at once, and under reduced motion it only fades, since a fade moves nothing. The highlight moves at once. A list that shows again, as a popover opens, draws its check at rest.

import { Check } from 'lucide-react';

<GlyphsProvider glyphs={{ check: <Check /> }}>
  <OptionList.Root aria-label="Fruit" value={value} onValueChange={setValue}>
    <OptionList.Option value="apple">Apple</OptionList.Option>
    <OptionList.Option value="pear">Pear</OptionList.Option>
  </OptionList.Root>
</GlyphsProvider>

Accessible composition

Todae handles: OptionList.Root is a role="listbox" with aria-activedescendant on the active option, and aria-multiselectable in multiple mode. Each OptionList.Option is a role="option" with aria-selected, aria-disabled when disabled, and an id built from the list's id and its value. With an OptionList.OptionDetail, the option is named by its title and then its detail, through aria-labelledby. The arrow keys, Home and End skip disabled options and stop at the ends. Typing moves to the next option whose title starts with what was typed: one letter, or the same letter again, cycles through those options, and a pause of half a second starts a new search. The detail is not part of that search. A Space joins a search under way, and otherwise selects. Keys with Ctrl, Meta or Alt, and the move keys with Shift, are left to the page, and a key pressed in a field inside the list stays with that field. An option with aria-disabled and no disabled stays reachable: the keys and a click make it active, but it cannot be selected. An option the keyboard moves to scrolls into view inside its scroll box. Focus stays on the list, or on the input that owns it.

You supply: A name with aria-label, or aria-labelledby pointing at a visible label; the type does not require one. A title that reads well on its own, since the name starts with it. A detail that reads well after the title, since the name goes on with it. When an input owns focus, wire it with useCombobox, which gives the list tabIndex={-1} and puts aria-activedescendant, aria-controls and aria-expanded on the input.

Watch for: Escape is not handled, so a list in your own overlay needs something else to close on Escape, such as Popover. Two lists with the same id give their options the same ids. tabIndex={-1} without an input that carries aria-activedescendant leaves the list out of keyboard reach.

When to use

When: Overlay listbox inside Popover or BottomSheet. Single or multiple string options. Keyboard listbox pattern.

When not: Choices that stay on the page → Radio or Checkbox. Do not dual-wire the same value to Radio/Checkbox.

Props

OptionList.Root props
NameTypeDescription
selectionMode"single" | "multiple"

Single fires onValueChange(string). Multiple fires onValueChange(string[]).

Default: "single"

value Requiredstring | null | readonly string[]

Selected value, or values when selectionMode is multiple.

onValueChange Required((value: string) => void)| ((value: string[]) => void)

Selection change. Single passes a string. Multiple passes the next array.

idstring

Listbox id. Auto-generated when omitted. Option ids derive from it.

tabIndexnumber

Listbox tabIndex. Pass -1 when a combobox input owns focus.

Default: 0

activeValuestring | null

Controlled highlighted value. Omit to keep highlight inside the list.

onActiveValueChange(value: string | null) => void

Fires when keyboard or pointer moves the highlight.

aria-labelstring

Name when no visible label is present.

OptionList.Option props
NameTypeDescription
value Requiredstring

Selection value.

children RequiredReact.ReactNode

Title. A string, plus one OptionList.OptionDetail for a second line.

disabledboolean

Skips pointer and keyboard selection. Use aria-disabled instead of disabled for an option that is unavailable for now but stays reachable.

Default: false

OptionList.OptionDetail props
NameTypeDescription
childrenReact.ReactNode

Detail text, read in the option name after the title.