This page as markdown: /disclosure-picker.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

DisclosurePicker

Status: stable

A property row that names the current value and opens its list in place, beneath the row, instead of in a popup — for a tool panel or settings column where the choice is made while looking at what it changes. Built on Collapsible; the list is a listbox — arrow keys move, Enter or a click picks, applies and closes — and an optional search field filters long lists.

Keywords: disclosure picker, inline picker, in-place select, expanding list, property row, font picker, preset picker, inspector, picker row

Usage

Use DisclosurePicker for one-of-many choices in a docked panel or inspector where a popup would cover the preview the choice is about: the row shows the current value (in its own face, with a tile, as the content warrants), and the list opens beneath it, pushing the panel down. Use Select for a form field or anywhere a popup is fine; use Combobox when people type to find an option among hundreds; use RadioGroup or RadioCard when every option should stay visible. Nothing applies while arrowing through the list — only Enter, Space or a click picks — so it suits choices with a cost (a confirm, a font load, a reset); where each option should apply as focus lands on it, that is a radio group (ThemeSelector, RadioGroup).

Best practices

Anatomy

Part Required Description
DisclosurePicker yes Root. Owns open state, size, focus return and scroll-into-view.
DisclosurePickerTrigger yes The row: optional label caption, optional media, the value, and a chevron that flips when open.
DisclosurePickerPanel yes What opens beneath the row: the opt-in search field, then the list.
DisclosurePickerList no A listbox of options that scrolls past 16rem. Arrow keys move; Enter, Space or a click picks.
DisclosurePickerOption no One option row, with optional leading media and trailing note. Chosen, it lifts out of the well; focused, it takes the ring.
DisclosurePickerEmpty no The no-match line, rendered in place of the list when a search filters everything out.

Subcomponents

Name Type Description
DisclosurePickerTrigger { label?: ReactNode; media?: ReactNode; children?: ReactNode } + Base UI Collapsible.Trigger props The row. label is a muted leading caption on a fixed column so stacked rows align; media a leading visual (a ThemePreview tile); children the value, truncated on one line. ArrowDown opens it, and steps into the list once open.
DisclosurePickerPanel { search?: { value: string; onValueChange(value: string): void; placeholder?: string; label?: string } } + Collapsible.Panel props Opens beneath the row. search opts in to a SearchInput above the list (off by default); it is controlled because the consumer filters, and it is cleared when the row closes. Escape clears a query first, then closes; ArrowDown in the field steps into the list.
DisclosurePickerList { value: string; onValueChange(value: string): void; aria-label?: string } + div props A listbox. ArrowUp/ArrowDown, Home/End and type-ahead move focus without applying anything (ArrowUp from the first option returns to the search field); Enter, Space or a click picks the focused option — onValueChange fires once, only when it differs from value — and closes the row. Escape closes without a pick.
DisclosurePickerOption { value: string; children?: ReactNode; media?: ReactNode; note?: ReactNode; disabled?: boolean; textValue?: string; onRemove?: () => void; removeLabel?: string } One option row. media is a leading visual (a ThemePreview tile); note a muted trailing annotation — options without one show a check when chosen. disabled skips it for the keyboard and refuses the pick; textValue is what type-ahead matches when the name is not plain text. onRemove makes the option removable — for entries the person added (an imported preset, a saved font): a trash glyph at the row's end on hover or focus (always on touch), and Delete or Backspace on the focused row; removing never picks, and focus moves to a neighbour first. removeLabel is the glyph's tooltip.
DisclosurePickerEmpty { children?: ReactNode } The no-match line, rendered in place of the list.
useDisclosurePicker () => { open: boolean; close(): void; size: "md" | "sm" | "xs" } For a list the picker does not own (a Tree) that should close the row when something is picked.

Props

Name Type Default Description
open boolean — Controlled open state. Pair with onOpenChange.
defaultOpen boolean false Uncontrolled initial open state.
onOpenChange (open: boolean) => void — Called with the next open state — from the trigger, a pick, or Escape.
size "md" | "sm" | "xs" "md" md is a --control-md row (40px comfortable) in a settings column, its own well when closed. sm is the same row one rung down (--control-sm), for a toolbar beside sm Selects and buttons. xs is the property-grid rung: a --control-xs row on the inset panel-field fill with ui-tier type. Height, padding, radius, type and surface move together.
className string — Merged onto the root (layout only — the look comes from size).
name string — Submits value with a form under this name, through a visually hidden input that stays mounted while the row is closed (the list that holds the value does not). The submitted string is the chosen option's value, exactly as given.
value string — The value submitted under name — pass the same value the list holds.
form string — Id of a form elsewhere on the page that the value belongs to.
required boolean — Blocks native form submission while value is empty; the browser's message focuses the row.
id / aria-describedby / aria-invalid string / string / boolean — Land on the trigger, the labelable control, not the root — so a wrapping Field's label names the row and its description and error are announced with it.

Tokens used

foreground, muted-foreground, popover, hairline, panel-field, panel-field-hover, ring, accent

Motion

Accessibility

Related

Examples

In a form

import { DisclosurePicker, DisclosurePickerList, DisclosurePickerOption, DisclosurePickerPanel, DisclosurePickerTrigger, Field } from "@sableui/react"

<Field label="Text size" required>
  <DisclosurePicker name="text-size" value={textSize}>
    <DisclosurePickerTrigger>{textSize}</DisclosurePickerTrigger>
    <DisclosurePickerPanel>
      <DisclosurePickerList aria-label="Text size" value={textSize} onValueChange={setTextSize}>
        <DisclosurePickerOption value="Small">Small</DisclosurePickerOption>
        <DisclosurePickerOption value="Medium">Medium</DisclosurePickerOption>
        <DisclosurePickerOption value="Large">Large</DisclosurePickerOption>
      </DisclosurePickerList>
    </DisclosurePickerPanel>
  </DisclosurePicker>
</Field>

A short list — no search

import { DisclosurePicker, DisclosurePickerList, DisclosurePickerOption, DisclosurePickerPanel, DisclosurePickerTrigger } from "@sableui/react"

const [preset, setPreset] = useState("comfortable")
const [open, setOpen] = useState(false)
<DisclosurePicker open={open} onOpenChange={setOpen} className="w-72">
  <DisclosurePickerTrigger label="Density">{preset === "compact" ? "Compact" : "Comfortable"}</DisclosurePickerTrigger>
  <DisclosurePickerPanel>
    <DisclosurePickerList aria-label="Density" value={preset} onValueChange={setPreset}>
      <DisclosurePickerOption value="comfortable">Comfortable</DisclosurePickerOption>
      <DisclosurePickerOption value="compact">Compact</DisclosurePickerOption>
    </DisclosurePickerList>
  </DisclosurePickerPanel>
</DisclosurePicker>

A long list — search opted in

import { DisclosurePicker, DisclosurePickerEmpty, DisclosurePickerList, DisclosurePickerOption, DisclosurePickerPanel, DisclosurePickerTrigger } from "@sableui/react"

const COUNTRIES = ["Argentina", "Australia", "Austria", "Belgium", "Brazil", "Canada", "Chile", "Denmark", "Finland", "France", "Germany", "Ireland", "Italy", "Japan", "Mexico", "Norway", "Portugal", "Spain", "Sweden"]
const [country, setCountry] = useState("Canada")
const [query, setQuery] = useState("")
const shown = COUNTRIES.filter((name) => name.toLowerCase().includes(query.trim().toLowerCase()))
<DisclosurePicker className="w-72">
  <DisclosurePickerTrigger label="Country">{country}</DisclosurePickerTrigger>
  <DisclosurePickerPanel search={{ value: query, onValueChange: setQuery, placeholder: `Search ${COUNTRIES.length} countries` }}>
    {shown.length > 0 ? (
      <DisclosurePickerList aria-label="Country" value={country} onValueChange={setCountry}>
        {shown.map((name) => (
          <DisclosurePickerOption key={name} value={name}>{name}</DisclosurePickerOption>
        ))}
      </DisclosurePickerList>
    ) : (
      <DisclosurePickerEmpty>No countries match “{query}”.</DisclosurePickerEmpty>
    )}
  </DisclosurePickerPanel>
</DisclosurePicker>

A theme picker — media tiles, commit on Enter

import { DisclosurePicker, DisclosurePickerList, DisclosurePickerOption, DisclosurePickerPanel, DisclosurePickerTrigger, ThemePreview, useSableTheme } from "@sableui/react"

const { themeId, setThemeId, themes, mode } = useSableTheme()
const current = themes.find((theme) => theme.id === themeId)
<DisclosurePicker>
  <DisclosurePickerTrigger aria-label={`Theme: ${current?.label}`} media={current ? <ThemePreview theme={current} mode={mode} size="sm" /> : null}>
    {current?.label}
  </DisclosurePickerTrigger>
  <DisclosurePickerPanel>
    <DisclosurePickerList aria-label="Theme" value={themeId} onValueChange={setThemeId}>
      {themes.map((theme) => (
        <DisclosurePickerOption key={theme.id} value={theme.id} media={<ThemePreview theme={theme} mode={mode} size="sm" />}>
          {theme.label}
        </DisclosurePickerOption>
      ))}
    </DisclosurePickerList>
  </DisclosurePickerPanel>
</DisclosurePicker>

Property-grid rung

import { Density, DisclosurePicker, DisclosurePickerList, DisclosurePickerOption, DisclosurePickerPanel, DisclosurePickerTrigger } from "@sableui/react"

const [blend, setBlend] = useState("normal")
<Density value="compact" className="w-64">
  <DisclosurePicker size="xs">
    <DisclosurePickerTrigger label="Blend">{blend}</DisclosurePickerTrigger>
    <DisclosurePickerPanel>
      <DisclosurePickerList aria-label="Blend mode" value={blend} onValueChange={setBlend}>
        <DisclosurePickerOption value="normal">normal</DisclosurePickerOption>
        <DisclosurePickerOption value="multiply">multiply</DisclosurePickerOption>
        <DisclosurePickerOption value="screen">screen</DisclosurePickerOption>
      </DisclosurePickerList>
    </DisclosurePickerPanel>
  </DisclosurePicker>
</Density>