Talisman LogoTalisman Logo Design System
Browse documentation
Components

Multiple selector

A searchable field that lets people pick several options from a list and shows the choices as removable badges.

Stableimport { MultipleSelector } from "@repo/ui/multi-select";Source

Select the field, type to filter and press Enter to add an option. Select a badge to remove it.

When to use

  • To choose several values from a known list, such as document types, reviewers or labels.
  • To filter a table by more than one value at once.
  • When the list is long enough to need search.

When not to use

  • Choosing a single value. Use a Combobox or a Select.
  • Fewer than five options that fit on the page. Use checkboxes.
  • Free text values with no list, such as process numbers. Use the creatable multi-select.
  • A choice that depends on another one. Use the cascading multi-selector.

States

Collapsed badges

When more options are selected than collapseSelectedTo, the extra ones move into a +N badge that opens the full list.

Disabled

Examples

Grouped options

Use groupBy with the name of an option field to group the list under headings.

Search and create

onSearchSync filters options in memory. Use onSearch for a request to the server, and creatable to let people add a value that is not in the list.

Limit the selection

maxSelected stops new selections and calls onMaxSelected. Tell the user why nothing happened.

Fixed options

An option with fixed: true stays selected and has no remove button.

Content

  • Name the field by what it holds: “Tipos de documento”, “Revisores”.
  • Placeholders say what to do: “Selecione os tipos”, not “Digite aqui”.
  • Pass emptyIndicator with a short message, such as “Nenhum tipo encontrado.”
  • Option labels are short and distinct. Long labels are truncated and show a tooltip with the full text.

Accessibility

  • The list is built on cmdk: arrow keys move through the options, Enter selects, and typing filters.
  • Backspace or Delete in an empty input removes the last badge. Escape closes the list.
  • The input has no visible label of its own. Pass an accessible name with inputProps={{ "aria-label": "…" }} and keep a visible label next to the field.
  • Each badge is a button. Fixed and disabled badges set aria-disabled.
  • Badges and the +N button show a focus ring with focus-visible.
  • The list renders in a portal on document.body. Inside a dialog, pass dropdownContainer so the list stays inside the focus trap and scrolls.

Code

import { MultipleSelector } from "@repo/ui/multi-select";
import type { Option } from "@repo/ui/multi-select";

const [value, setValue] = useState<Option[]>([]);

<MultipleSelector
  inputProps={{ "aria-label": "Tipos de documento" }}
  onChange={setValue}
  options={[
    { label: "Petição inicial", value: "peticao_inicial" },
    { label: "Contestação", value: "contestacao" },
  ]}
  placeholder="Selecione os tipos"
  value={value}
/>;

Props

MultipleSelector
PropTypeDefaultDescription
collapseSelectedTonumber3Shows only the first N selected badges and a +N badge for the rest
creatablebooleanfalseLets people create an option when nothing matches
disabledbooleanfalseBlocks typing and removing badges
groupBystring—Key of the option field used to group the list
hideClearAllButtonbooleanfalseHides the button that clears the whole selection
hidePlaceholderWhenSelectedbooleantrueHides the placeholder once something is selected
maxSelectednumberNumber.MAX_SAFE_INTEGERMaximum number of selected options
placeholderstring—Hint shown in the input
More props
PropTypeDefaultDescription
valueOption[]—Selected options. The component keeps its own copy and calls onChange.
optionsOption[]—The options shown in the list, controlled by the caller.
defaultOptionsOption[][]Initial options when the list is built from search results.
onChange(options: Option[]) => void—Called with the full selection after every change.
onSearch(value: string) => Promise<Option[]>—Async search. Debounced by `delay` (500ms by default).
onSearchSync(value: string) => Option[]—Synchronous search. Never shows the loading indicator.
triggerSearchOnFocusbooleanfalseRuns onSearch when the input receives focus, to load initial options.
onMaxSelected(maxLimit: number) => void—Called when the user tries to exceed maxSelected.
emptyIndicatorReactNode—Content shown when no option matches.
loadingIndicatorReactNode"Carregando..."Content shown while an async search runs.
isLoadingboolean—Forces the loading state.
clearAllLabelstring"Limpar todos"Label of the clear button inside the +N popover.
showAllSelectedOnClickbooleantrueMakes the +N badge open a popover with every selected option.
dropdownContainerHTMLElement | null—Portal target for the list. Use it inside dialogs and sheets.
inputPropsCommandInput props—Props for the input, such as aria-label and onValueChange.
badgeClassNamestring—Extra classes for the badges, for spacing only.
Option
PropTypeDefaultDescription
valuestring—Unique identifier.
labelstring—Text shown in the list and in the badge.
disableboolean—Shows the option but blocks selecting it.
fixedboolean—Keeps the option selected, without a remove button.
[key: string]string | boolean | undefined—Any extra field. Name one in groupBy to group options.

Known issues

Issue Effect
Disabled and fixed badges use opacity-60, and the badge × icons use opacity-50. Opacity lowers contrast of the text and icons. Disabled state should use disabled tokens.
The clear-all button (aria-label="Limpar seleção") has no focus style, no hover background and a 24px hit area. Keyboard users cannot see when it has focus. It is at the minimum size.
aria-label="Limpar seleção" and aria-label="Ver mais N selecionados" are hardcoded in Portuguese. Apps cannot translate them. Only clearAllLabel and loadingIndicator are props.
The field has no built-in accessible name. Without inputProps["aria-label"] a screen reader announces an unnamed text field.
The container forces !bg-primary with an important modifier. Callers cannot change the background with className.
showAllSelectedOnHover is deprecated, and its name says hover. It only keeps the +N popover enabled and still opens on click. The name misleads call sites.
Edit this page on GitHub