Skip to Content
NarakUI

Multi-select Filter

A filter chip for toolbars that narrows a list or report to one or more values.

Basic usage

Pass items, the controlled selectedIds, and onChange. With nothing narrowed the chip is a dashed button with label and iconStart. Once the selection narrows the results, the chip shows the label, the first pick with a +N count, and an X that resets the filter. Hover the chip to see every pick.

renderItemStart adds an icon or avatar to each row; renderSelectionIcons stacks the picked items' icons in the chip. MultiSelectSelectionIcons draws that stack for you.

Empty or all selected

By default, selecting every item means no filter, like the Topic chip here. The X returns to that state, and so does unchecking the last row. With everything selected, the footer's Clear all empties the checkboxes without filtering, and the next pick selects only that row.

When the items are only part of the possible values, such as a few statuses, pass allowEmpty. An empty selection is then the cleared state, the chip stays active while anything is picked, and the X clears to []. Short lists can hide the search with showSearch={false} and the per-row only button with showOnlyButton={false}.

Groups

Pass groups instead of items to show headed sections in your order. Without groups, picked rows move to the top each time the menu opens.

Selector style

For a picker that always has a value, pass inactiveTriggerMode="secondary" and showInactiveTriggerChevron so the cleared chip reads as a select. allSelectedTriggerLabel names the full selection, and showSelectionIconsWhenAllSelected keeps the icons in the chip.

Installation

pnpm dlx shadcn@latest add @narakui/multi-select-filter

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/multi-select-filter.json.

Usage

onChange receives the next selection. To handle each action yourself, pass onToggle, onSelectOnly, onSelectAll, and onClearAll; each falls back to onChange when omitted.

For server-side search, pass disableClientFiltering, read the query from onSearchChange, and set searchInputLoading while results load. Put an infinite-scroll sentinel in listFooter. When items is only the loaded page of a larger set, pass allSelectableIds or selectionActive so the chip knows whether the filter is reset.

Inside a dialog, pass withRadixPortal={false} so the menu scrolls.

import { MultiSelectFilter } from '@/components/ui/multi-select-filter';
<MultiSelectFilter
  label="Topic"
  items={topics}
  selectedIds={selectedIds}
  onChange={setSelectedIds}
/>

Properties

Data and selection

PropTypeDefaultDescription
label (Required)string—Name of the filter, shown on the chip.
itemsT[]—Options, each { id, name, triggerName? }. Use either items or groups.
groupsMultiSelectFilterGroup<T>[]—Headed sections, each { id, heading?, items, renderItem? }, shown in order.
selectedIds (Required)string[]—Controlled selection.
allowEmptybooleanfalseTreats an empty selection as the cleared state, so selecting every item still filters.
allowEmptySelectionbooleanfalseKeeps all selected as the cleared state but lets the last item be unchecked.
allSelectableIdsstring[]—Every selectable id, when items shows only part of them.
selectionActiveboolean—Controls whether the chip shows as active, for selections over paginated items.
getItemDisabled(item: T) => boolean—Disables a row so it cannot be toggled.
renderItemDisabledTooltip(item: T) => ReactNode—Tooltip on a disabled row that explains why.

Callbacks

PropTypeDefaultDescription
onChange(ids: string[]) => void—Called with the next selection. The handlers below fall back to it.
onToggle(id: string) => void—Called when a row is checked or unchecked.
onSelectOnly(id: string) => void—Called when a row's only button is clicked.
onSelectAll() => void—Called by Select all and by the X when empty is not the cleared state.
onClearAll() => void—Called by Clear all.
onSearchChange(search: string) => void—Called when the query changes.
onOpenChange(open: boolean) => void—Called when the menu opens or closes.

Trigger

PropTypeDefaultDescription
iconStartMultiSelectFilterIconValue—Icon on the cleared chip.
size'micro' | 'small' | 'regular' | 'large''regular'Chip size. Use small in compact tables and menus.
inactiveTriggerModeButtonMode'dashed'Button style of the cleared chip.
showInactiveTriggerChevronbooleanfalseShows a chevron on the cleared chip.
renderSelectionIcons(selectedItems: T[]) => ReactNode—Icons of the picked items, shown before the chip's label.
showSelectionIconsWhenAllSelectedbooleanfalseAlso shows the selection icons when every item is selected.
hideTriggerLabelTextbooleanfalseShows only the selection icons in the chip; the label stays for screen readers.
allSelectedTriggerLabelReactNode—Chip label when every item is selected. Defaults to label.
emptyTriggerLabelReactNode—Chip label when nothing is selected. Defaults to label.
triggerLabelReactNode—Replaces the first-pick and +N preview in the active chip, for example with a skeleton.
triggerTooltipReactNode—Replaces the hover list of picks. Pass null to hide it.
hasNumericLabelsbooleanfalseSeparates the first pick from +N with a comma, for labels such as 18-25.
disabledbooleanfalseDisables the chip.
triggerClassNamestring—Classes for the center button of the chip.
triggerContainerClassNamestring—Classes for the clickable part of the chip.
PropTypeDefaultDescription
renderItemStart(item: T) => MultiSelectFilterIconValue—Icon or avatar before each row's label.
renderItemLabel(item: T) => ReactNode—Replaces each row's label.
renderItemEnd(item: T) => MultiSelectFilterIconValue—Content at the end of each row.
showSearchbooleantrueShows the search input.
searchPlaceholderstring'Search'Placeholder of the search input.
searchTextstring—Controlled query.
disableClientFilteringbooleanfalseSkips the built-in name filter, for server-side search.
searchInputLoadingbooleanfalseShows a spinner in the search input.
noResultsLabelReactNode'No results found.'Shown when search matches no row.
showOnlyButtonbooleantrueShows the only button on row hover.
itemsCountLabel(count: number) => ReactNodecount => `${count} items` Selected count in the footer.
hideEmptyCountbooleantrueHides the footer count when nothing is selected.
hideSelectAllButtonbooleanfalseHides the footer's Select all and Clear all button.
hideClearAllButtonbooleanfalseHides only Clear all.
hideFooterbooleanfalseHides the footer.
topRowReactNode—Content between the search input and the list.
bottomRowReactNode—Content between the list and the footer.
listFooterReactNode—Content at the end of the scrolling list, such as a load-more sentinel.
footerExtraReactNode—Content below the footer.
emptyStateReactNode—Shown in place of the list when there are no items.
align'start' | 'center' | 'end''start'Alignment of the menu relative to the chip. Use end at the trailing edge of a toolbar.
defaultOpenbooleanfalseOpens the menu on mount.
withRadixPortalbooleantrueRenders the menu in a portal. Set to false inside a dialog.
classNamestring—Classes for the outer wrapper.