Faceted select Documentation has not yet been reviewed by a human.
Use SelectFaceted to collect filters for a list of issues, orders, or other
records. Each category is a facet, such as status or assignee. The Filter
button shows how many facets are active, and each active facet shows a summary
of its value in the menu.
Playground
Filter by category
Open Filter and choose Status to set a single value or Assignee to choose several. Title contains accepts text and applies it on Enter or when the field loses focus. Clear all resets the filters.
This example shares one filter record between the menu and the controls beside it. Use those controls to edit an active filter without reopening the facet menu. Each editable control uses the facet label as its accessible name. Open Recency to pick a preset or set From and To independently. In Min duration, enter a number of seconds to apply the comparison.
import { useState } from 'react'import { Button, Input, Select, SelectFaceted, Tag } from '@antadesign/anta/bundle'
// FACETS holds the app's option lists and custom facet editors.// The recency and duration helpers format the corresponding filter values.
const isSet = (v: unknown) => !(v == null || v === '' || (Array.isArray(v) && v.length === 0))
export function Demo() { const [value, setValue] = useState<Record<string, unknown>>({ assignee: ['Alice Nguyen'], status: 'open', title: 'crash' }) const setFacet = (key: string, v: unknown) => setValue((prev) => { const next = { ...prev } if (isSet(v)) next[key] = v else delete next[key] return next }) // Keep a text/custom result chip mounted while it's focused, even if emptied — so // backspacing to empty doesn't yank the field mid-edit (only the Clear button or // blurring an empty field removes it). const [focusedKey, setFocusedKey] = useState<string | null>(null) const active = FACETS.filter((f) => isSet(value[f.key]) || f.key === focusedKey) return ( <div style={{ display: 'flex', flexDirection: 'row', flexWrap: 'wrap', gap: '12px', alignItems: 'center', width: '100%' }}> <SelectFaceted facets={FACETS} value={value} onValueChange={setValue} searchable /> {active.length > 0 && ( <div style={{ display: 'flex', flexDirection: 'row', flexWrap: 'wrap', gap: '8px', alignItems: 'center', maxWidth: '100%' }}> {active.map((facet) => { // Options facets → an editable Select; the key rides the leading slot. if (facet.kind === 'single' || facet.kind === 'multiple') return ( <Select key={facet.key} selection={facet.kind} indicator={facet.kind === 'single' ? 'check' : undefined} options={facet.options} renderOption={facet.renderOption} value={(value[facet.key] ?? (facet.kind === 'single' ? null : [])) as any} onValueChange={(v: any) => setFacet(facet.key, v)} leading={`${facet.label}:`} aria-label={facet.label} filter={facet.filter} clearable className="sf-chip" /> ) // Free-form text → an editable Input; clearing it drops the filter. if (facet.kind === 'text') return ( <Input key={facet.key} value={(value[facet.key] as string) ?? ''} leading={`${facet.label}:`} clearable dimActions className="sf-chip" onFocus={() => setFocusedKey(facet.key)} onBlur={() => setFocusedKey(null)} onInput={(e: any) => setFacet(facet.key, e.currentTarget.value || undefined)} onClearInput={() => { setFocusedKey(null) setFacet(facet.key, undefined) }} /> ) if (facet.key === 'recency') { const recency = value.recency as Recency return <Tag key={facet.key} label="Recency" value={recencySummary(recency)} /> } // Custom (duration) → an Input editing its `min`. return ( <Input key={facet.key} value={((value[facet.key] as any)?.min ?? '') as string} leading={`${facet.label} ${durationSign((value[facet.key] as any)?.comparison)}:`} clearable dimActions className="sf-chip" onFocus={() => setFocusedKey(facet.key)} onBlur={() => setFocusedKey(null)} onInput={(e: any) => setFacet(facet.key, e.currentTarget.value.trim() ? { min: e.currentTarget.value, comparison: (value[facet.key] as any)?.comparison ?? 'gte' } : undefined) } onClearInput={() => { setFocusedKey(null) setFacet(facet.key, undefined) }} /> ) })} {active.length > 1 && ( // Once more than one result is showing, a single control resets them // all — pushed to the right of the last chip. <Button priority="tertiary" icon="filter-x" label="Clear all" style={{ marginLeft: 'auto' }} onClick={() => { setFocusedKey(null) setValue({}) }} /> )} </div> )} </div> )}.sf-chip { width: 240px; max-width: 100%; }Search options
Pass searchable to let people find options across all single- and
multiple-choice facets from Filter. Try entering production to find
env production under Metadata. Set filter: true on a facet to add a
search field inside that facet. The two searches keep separate queries.
Search fields and custom editors open in dialogs. Choice facets without a search
field open as menus.
Built-in search matches the option’s value, label, and hint without
regard to case and treats consecutive whitespace as one separator. A custom
filter receives the original query in both search locations, including
leading and trailing spaces. It also receives an empty query within a facet.
An empty or whitespace-only global query shows the facet list. If you reuse a
Select predicate, account for Select passing a trimmed query.
Custom option content
Use renderOption when the option needs more structure than a label and hint.
The Metadata facet renders each key and value as a Tag in the facet and in
global search results. Keep searchable text in value, label, or hint.
The row still handles selection and renders its indicator. Return null to
use the default layout for an option.
renderOption: (option) => ( <Tag label={String(option.dataKey)} value={String(option.dataValue)} />)Tone
Use toneCount to emphasize the active-filter count and toneSummary to
color the selected-value chips. Both default to "neutral". In this example
both triggers start with one active facet. Open each to compare its Status
summary chip.
import { SelectFaceted, type SelectFacet } from '@antadesign/anta/bundle'
const facets: SelectFacet[] = [{ key: 'status', label: 'Status', kind: 'single', options: [ { value: 'open', label: 'Open' }, { value: 'closed', label: 'Closed' }, ],}]
export function Demo() { return ( <> <SelectFaceted label="Brand count" facets={facets} defaultValue={{ status: 'open' }} toneCount="brand" /> <SelectFaceted label="Info summary" facets={facets} defaultValue={{ status: 'open' }} toneSummary="info" /> </> )}Use tone for option rows. Pair it with toneScope="selected" to apply the
color only to selected rows. An individual option can override either setting.
Open Label in the first example to see options with their own tones.
Value and changes
Use value and onValueChange when the application owns the filters. Apply
the returned record to your data, or use defaultValue to set the initial
selection and let SelectFaceted manage it.
The record uses your facet keys. Two facets can share an option and still
store independent values. For example, { owner: 'alice', assignee: ['alice'] }
has two active facets. Clearing a facet removes its key. To release control
while keeping the latest record, omit value or pass undefined.
The second argument to onValueChange identifies the changed facet or
reports { all: true } when the user selects Clear all. Check
'all' in attrs before reading attrs.facet.
<SelectFaceted facets={facets} value={filters} onValueChange={setFilters}/>Value types
single and multiple facets use Select option
values: string, number, or boolean (OptionValue). Anta compares them
with === and returns them unchanged. For a non-primitive value, use a stable
primitive key such as a date’s ISO string or a record ID. Look up the full value
with that key. Use a custom facet when the facet value is an object, such as a
date range or numeric comparison. Its editor can return any value of type V.
Custom facet
Use a custom facet for a filter that needs its own editor, such as a minimum
duration or a date range. Type it as SelectFacetCustom<V> to share the same
value type between render and summary. Call ctx.onChange with the next
value or undefined to clear it. Use ctx.close() when the editor should
close after a change.
Return the visible chip content from summary. Return null to hide the chip.
Long summaries truncate to fit the menu.
Enter a minimum duration
Open Min duration and enter a number of seconds. Keep the raw text in the facet so people can type a decimal. Parse it when applying the filter.
import { Input, SelectFaceted, type SelectFacetCustom } from '@antadesign/anta/bundle'
const duration: SelectFacetCustom<string> = { key: 'duration', label: 'Min duration', kind: 'custom', render: (ctx) => ( <Input aria-label="Minimum duration in seconds" type="text" inputMode="decimal" size="small" placeholder="seconds" value={ctx.value ?? ''} onInput={(e) => ctx.onChange(e.currentTarget.value || undefined)} /> ), summary: (v) => `≥ ${v}s`,}
<SelectFaceted facets={[duration]} value={value} onValueChange={setValue} />
const raw = value.durationconst minimum = typeof raw === 'string' && raw.trim() ? Number(raw) : NaNconst filteredRows = rows.filter((row) => Number.isNaN(minimum) || row.seconds >= minimum)Pick a date
Open Created after and choose a date. The inline Calendar uses ISO date
strings, and the facet stores a Date. Use Calendar’s onStateChange to
apply the pick when you supply a controlled value.
import { Calendar, SelectFaceted, type SelectFacetCustom } from '@antadesign/anta/bundle'
const pad = (n: number) => String(n).padStart(2, '0')const toISO = (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}` // Date → "2026-01-01"const fromISO = (s: string | null) => (s ? new Date(`${s}T00:00:00`) : undefined) // ISO → Date | undefined
const since: SelectFacetCustom<Date> = { key: 'since', label: 'Created after', kind: 'custom', icon: 'calendar', render: (ctx) => ( <Calendar size="small" value={ctx.value ? toISO(ctx.value) : ''} // Controlled: apply the pick in onStateChange (onValueChange fires only after // value changes, so it can't drive a controlled Calendar). onStateChange={(_e, { next }) => ctx.onChange(fromISO(next))} /> ), summary: (d) => d.toLocaleDateString(),}
<SelectFaceted facets={[since]} value={value} onValueChange={setValue} />
const pickedDate = value.sinceconst filteredRows = rows.filter((row) => !(pickedDate instanceof Date) || row.createdAt >= pickedDate)Combine presets with a date range
This editor uses MenuItem rows with radio indicators for the presets.
Select Custom range to show From and To. The facet
value is either { preset } or { from, to }. Resolve either shape to a date range before filtering your data. Each
InputDate calendar opens above the facet menu without closing it.
import { InputDate, MenuItem, SelectFaceted, type SelectFacetCustom } from '@antadesign/anta/bundle'
type Recency = { preset: 'today' | 'yesterday' | 'last14' | 'last30' } | { from: string; to: string }
const PRESETS = [ { value: 'today', label: 'Today' }, { value: 'yesterday', label: 'Yesterday' }, { value: 'last14', label: 'Last 14 days' }, { value: 'last30', label: 'Last 30 days' }, { value: 'custom', label: 'Custom range' },] as constconst PRESET_LABELS: Record<string, string> = { today: 'Today', yesterday: 'Yesterday', last14: 'Last 14 days', last30: 'Last 30 days',}
const isoDay = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`const daysAgo = (n: number) => { const x = new Date() x.setHours(0, 0, 0, 0) x.setDate(x.getDate() - n) return x}
const resolveRange = (r: Recency): { from: string; to: string } => { if ('from' in r) return r const today = isoDay(daysAgo(0)) switch (r.preset) { case 'today': return { from: today, to: today } case 'yesterday': { const y = isoDay(daysAgo(1)); return { from: y, to: y } } case 'last14': return { from: isoDay(daysAgo(13)), to: today } case 'last30': return { from: isoDay(daysAgo(29)), to: today } }}
const recency: SelectFacetCustom<Recency> = { key: 'recency', label: 'Recency', kind: 'custom', icon: 'calendar', summary: (v) => 'preset' in v ? PRESET_LABELS[v.preset] : v.from && v.to ? `${v.from} → ${v.to}` : 'Custom range', render: ({ value, onChange }) => { const mode = value == null ? '' : 'preset' in value ? value.preset : 'custom' const range = value && 'from' in value ? value : { from: '', to: '' } return ( <div style={{ minWidth: 360 }}> {PRESETS.map((preset) => ( <MenuItem key={preset.value} label={preset.label} selectionIndicator="radio" selected={mode === preset.value} data-menu-open onSelect={() => onChange(preset.value === 'custom' ? range : { preset: preset.value })} /> ))} {mode === 'custom' && ( <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: 8, padding: 8 }}> <InputDate size="small" label="From" clearable value={range.from} onValueChange={(from) => onChange({ from, to: range.to })} /> <InputDate size="small" label="To" clearable value={range.to} min={range.from || undefined} onValueChange={(to) => onChange({ from: range.from, to })} /> </div> )} </div> ) },}
<SelectFaceted facets={[recency]} value={value} onValueChange={setValue} />// Resolve the stored recency value with resolveRange before filtering rows.Open a calendar beside the editor
This version renders the presets as MenuItem rows and marks the selected row
with a check. Custom day reveals one InputDate. Its calendar opens to the
right with placement="right-start", which is useful when the trigger is on the
left side of a wide layout. placement and offset are passed to the
calendar’s Menu.
import { InputDate, MenuItem, SelectFaceted, type SelectFacetCustom } from '@antadesign/anta/bundle'
type Recency = { preset: 'today' | 'yesterday' | 'last14' | 'last30' } | { day: string }
const DAY_PRESETS = [ { value: 'today', label: 'Today' }, { value: 'yesterday', label: 'Yesterday' }, { value: 'last14', label: 'Last 14 days' }, { value: 'last30', label: 'Last 30 days' }, { value: 'custom', label: 'Custom day' },] as const
const PRESET_LABELS: Record<string, string> = { today: 'Today', yesterday: 'Yesterday', last14: 'Last 14 days', last30: 'Last 30 days',}
const recency: SelectFacetCustom<Recency> = { key: 'recency', label: 'Recency', kind: 'custom', icon: 'calendar', summary: (v) => ('preset' in v ? PRESET_LABELS[v.preset] : v.day || 'Custom day'), render: ({ value, onChange }) => { const mode = value == null ? '' : 'preset' in value ? value.preset : 'custom' const day = value && 'day' in value ? value.day : '' return ( <> {DAY_PRESETS.map((p) => ( <MenuItem key={p.value} label={p.label} selectionIndicator="check" selected={mode === p.value} data-menu-open onSelect={() => onChange(p.value === 'custom' ? { day } : { preset: p.value })} /> ))} {mode === 'custom' && ( <div data-menu-open style={{ padding: 8 }}> {/* opens the calendar to the right of the field */} <InputDate size="small" label="Day" placement="right-start" value={day} onValueChange={(d) => onChange({ day: d })} /> </div> )} </> ) },}
<SelectFaceted facets={[recency]} value={value} onValueChange={setValue} />// Apply the chosen day or resolve the preset to a date range before filtering. Component props
| Prop | Type | Default | Description |
|---|---|---|---|
| facets | SelectFacet[] | — | Categories to filter by. Each facet has a kind that determines its editor. |
| placement? | leftrightbottomtopbottom-startbottom-endtop-starttop-endright-startright-endleft-startleft-end | bottom-start | Preferred placement of the root filter menu relative to its trigger. The menu auto-flips vertically and clamps horizontally when needed. |
| offset? | number | 4 | Gap in pixels between the trigger and the filter menu. |
| value? | SelectFacetedValue | — | Controlled value record, keyed by facet. When provided, update it through
onValueChange. Leave it undefined for uncontrolled use; releasing control
retains the latest applied record. Inline records work correctly. For a
derived record, useMemo can avoid an extra component render when the parent
renders with unchanged inputs. Pass records held in state directly. |
| defaultValue? | SelectFacetedValue | — | Initial value for uncontrolled use. |
| onValueChange? | (value, attrs) => void | — | Fires after any facet changes. value is the whole new record (a facet key →
that facet's value; a cleared facet is absent). attrs says what changed:
{ facet, kind, value } for a single facet edit, or { all: true } for the
"Clear all" row — narrow on 'all' in attrs before reading facet. |
| label? | string | Filter | Default trigger's button label. |
| icon? | IconShape | filter | Default trigger's leading icon. |
| size? | smallmediumlarge | medium | Default trigger's button size. |
| priority? | primarysecondary | secondary | Default trigger's button priority. |
| disabled? | boolean | — | Disable the whole control. |
| tone? | neutralbrandcriticalinfosuccesswarningstring | — | Default option-row tone in facet flyouts. An option's own tone wins. |
| toneScope? | allselected | 'all' | Apply the default row tone in every state, or only to selected rows. An
option's own toneScope wins. |
| toneCount? | neutralbrandinfosuccesswarningcriticalstring | neutral | Tone of the active-filter count badge on the default trigger. |
| toneSummary? | neutralbrandinfosuccesswarningcriticalstring | neutral | Tone of the selected-value summary chips on facet rows. |
| searchable? | boolean | — | Adds a search field at the top of the root menu. It searches the options of
every single and multiple facet in one list. For example, "alice" can
appear under application-defined Assignee and Owner facets. text and
custom facets remain available when the search is empty. Each facet uses
its filter function when supplied, or the built-in substring match. |
| searchPlaceholder? | string | Filter… | Placeholder for the global search field. |
| clearable? | boolean | true | Show the per-facet "Clear" row and the "Clear all" row. |
| clearAllLabel? | string | Clear all | Label for the "Clear all" row. |
| renderTrigger? | (state) => ReactNode | — | Replaces the default Button with a trigger returned from this function.
Receives a SelectFacetedTriggerState. Return exactly one focusable element:
the menu is positioned relative to that element and opens when it is clicked.
Add aria-haspopup={searchable ? 'dialog' : 'menu'} and
aria-expanded={state.open} to the returned element, on a role that
supports them (an Anta Button already carries role="button"; otherwise
add role="combobox"). className, style, and other trigger props apply
only to the default Button, so add styling and attributes to the returned
element. |
Inherited props (className, id, slot, style, tabIndex, title)
| Prop | Type | Default | Description |
|---|---|---|---|
| className? | string | — | Adds CSS classes to the root element and preserves its existing classes. |
| id? | string | — | HTML id attribute. |
| slot? | string | — | Named slot in a parent web component, such as slot="header" in a <Dialog>. |
| style? | CSSProperties | — | Inline CSS styles on the root element. |
| tabIndex? | number | — | Tab order. Set to -1 to skip the element when tabbing. |
| title? | string | — | HTML title attribute, shown as a browser tooltip on hover. |
Plus every standard DOM event handler (onClick,
onFocus, onKeyDown, …) and any
data-* or aria-* attribute — forwarded as-is to
the underlying <a-*> element.
The SelectFacet type
facets takes a SelectFacet[]. Every facet has a key, label, and optional
icon. The kind field selects one of the shapes below.
single and multiple facets use the same options, filter, and selectAll
properties as Select. They use kind in place of Select’s
selection. text and custom do not use Select options. A single facet
returns one option value; a multiple facet returns an array of option values.
When selectAll is enabled, Alt-clicking an option in a multiple facet clears
the other values and selects that option. Use Option-click on macOS. After a
700ms hover, a tooltip beside the row describes the shortcut. Moving to another
row restarts the delay. An option’s tooltip replaces that hint; set it
to '' to hide the hint.
| Field | Type | Description |
|---|---|---|
key |
string |
The key for this facet’s value in the record. attrs.facet returns it. It must be unique in facets. |
label |
string |
The facet’s row label in the menu. |
icon |
IconShape |
Leading icon on the facet’s row. |
single (SelectFacetSingle) selects one option. Its value is the selected
option’s value, or is absent when cleared. Selecting the current option again
clears it.
| Field | Type | Description |
|---|---|---|
kind |
'single' |
Discriminant. |
options |
SelectItem[] |
The choices — bare strings or SelectOptions (groups / submenus flatten to their leaves). Option values may be string / number / boolean. |
filter |
FacetFilter |
Search field over this facet’s options: true for the built-in substring match, or (option, query) => boolean. |
multiple (SelectFacetMultiple) selects any number of options. Its value
is an array of the selected option values. An empty array clears it.
| Field | Type | Description |
|---|---|---|
kind |
'multiple' |
Discriminant. |
options |
SelectItem[] |
As single. |
filter |
FacetFilter |
As single. |
selectAll |
boolean |
A “Select all” row toggling every visible, enabled option. Default true. |
selectAllLabel |
string |
Label for that row. Default Select all. |
text (SelectFacetText) accepts a free-form string. It applies on Enter or
blur and is absent when empty.
| Field | Type | Description |
|---|---|---|
kind |
'text' |
Discriminant. |
placeholder |
string |
Placeholder for the text field. |
custom (SelectFacetCustom<V>) renders the editor supplied by render.
It can store a value of type V, including an object such as a date range.
| Field | Type | Description |
|---|---|---|
kind |
'custom' |
Discriminant. |
render |
(ctx) => ReactNode |
Renders the editor. ctx.value is the current V; ctx.onChange(next) sets it, and undefined clears the facet. ctx.close() closes the menu. |
summary |
(value: V) => ReactNode |
The chip on the facet’s row while a value is set. |
Styling
Set size and priority on the default trigger. To place its menu above the
trigger, pass placement="top-end". Use offset to set the gap in pixels.
The menu can flip or clamp to fit the available space.
className, style, and extra attributes apply to the default trigger.
When you supply renderTrigger, style and label your trigger there.
Scope text-editor padding to your trigger’s class and its adjacent menu.
Replace .roomy-text-filter with your own class. If your selector used
div[data-menu-open] for the old text editor, update it to
a-select-faceted-text. Open Title contains to see the increased padding.
Use external CSS for styling on pages with a strict content security policy. See Install and configure.
<SelectFaceted placement="top-end" offset={8} className="roomy-text-filter" facets={[{ key: 'title', label: 'Title contains', kind: 'text' }]}/>.roomy-text-filter + a-menu a-select-faceted-text { padding: 8px; }