Talisman LogoTalisman Logo Design System
Browse documentation
Components

Cascading multi-selector

A combobox for a main choice followed by a multi-select whose options depend on that choice.

Stableimport { CascadingMultiSelector } from "@repo/ui/cascading-multi-selector";Source

Choose a type first. When that type has purposes, the second field appears and receives focus.

When to use

  • When the second list depends on the first choice, such as the purposes that exist for each document type.
  • In dense rows or inline editing, where both fields sit side by side.

When not to use

States

With a selection

Type without secondary options

When the chosen primary value has no secondary options, the second field is not rendered.

Disabled

Content

  • Clear the secondary selection when the primary value changes. The component does not do it for you, and old badges may no longer be valid.
  • Placeholders say what to pick: “Selecione o tipo”, “Selecione as finalidades”.
  • Pass translated placeholders from the app. The defaults are Portuguese.

Accessibility

  • It combines a Combobox, built on Radix Popover and cmdk, and the multiple selector. Their keyboard behavior applies: arrow keys, Enter, Escape, and Backspace to remove the last badge.
  • After a primary selection the primary list closes and, when secondary options exist, focus moves to the secondary input. Focus does not move when there are none.
  • With initialFocusTarget="primary" the primary list opens on mount. Use it only for inline editing, where the user just asked to edit.
  • The secondary field shows one badge and a +N button when more are selected.

Code

import { CascadingMultiSelector } from "@repo/ui/cascading-multi-selector";

<CascadingMultiSelector
  onPrimaryChange={handlePrimaryChange}
  onSecondaryChange={setSecondary}
  primaryOptions={[{ label: "Contestação", value: "contestacao" }]}
  primaryPlaceholder="Selecione o tipo"
  primaryValue={primary}
  secondaryOptions={purposes}
  secondaryPlaceholder="Selecione as finalidades"
  selectedSecondary={secondary}
/>;

Props

CascadingMultiSelector
PropTypeDefaultDescription
badgeClassNamestring"h-5 text-xs"Extra classes for the badges of the secondary field
disabledboolean—Disables both fields
initialFocusTarget"primary" | "secondary" | "none"noneWhich field receives focus when the component mounts
multiTestIdstring"conditional-multi-selector"Test id of the secondary field
primaryNamestring"primary-selector"Name of the primary field
primaryPlaceholderstring"Selecione tipo"Hint of the primary field
secondaryPlaceholderstring"Selecione finalidades"Hint of the secondary field
More props
PropTypeDefaultDescription
primaryOptionsOption[]—Options of the primary combobox: { value, label, description? }.
primaryValuestring—Selected primary value. Use an empty string for none.
onPrimaryChange(value: string) => void—Called when a primary option is chosen.
secondaryOptionsOption[]—Options of the multi-select. When empty, the field is hidden.
selectedSecondaryOption[]—Selected secondary options.
onSecondaryChange(items: Option[]) => void—Called with the full secondary selection after every change.
classNamestring—Extra classes for the wrapper, for layout only.

Known issues

Issue Effect
Neither field receives an accessible name. The component does not pass ariaLabel to the combobox or aria-label to the secondary input. Screen readers announce the fields by placeholder or not at all. Apps cannot fix it from props.
The secondary field always collapses to one badge (collapseSelectedTo={1}) and sets showAllSelectedOnHover, a deprecated prop. Users must open +N to see every purpose. It cannot be changed through props.
The secondary field is forced to !h-10 and the primary trigger to h-10. Long selections cannot wrap, so badges are truncated.
It inherits the multiple selector issues: opacity-based disabled badges and a clear button with no focus style. See the multiple selector page.
Edit this page on GitHub