Raft Design System

Components · Inputs

TagFilter

A filter of several values that shows each value as a tag in the toolbar, with its own ×, a +N for the ones that don't fit, and a × that clears the filter.

ExperimentalAlso called Multi-select filter, Tag filter, ComboboxTagFilter, maxTagCount, clearable
import { TagFilter } from "@botiverse/raft-ui/wip";

TagFilter is a toolbar filter that takes several values and shows them. Unset, it is a PickerTriggerButton that says the filter's name. Applied, the whole filter is one info-soft group as high as the button: the name, which opens the list; a 24px tag for each value with its own ×; +N for the tags that don't fit; and, when clearable, a × that clears the filter. People see what the filter holds, take one value out, or clear it all, without opening the list (Select › Filters).

tag-filter/compositions/toolbar

When to use

SituationUse
A toolbar filter that can hold several values (statuses, people, channels, kinds of place)TagFilter (ComboboxTagFilter)
A toolbar filter that holds one value (a sort, one channel)A filter button that shows the value (PickerTriggerButton)
A filter people change seldom and set by habit, behind a Filter button that always says FilterFilterChip
Chosen values in a form field (people to add, labels)The combobox's own chips (Combobox)

Anatomy

  • TagFilter: the group, a role="group" named by the filter. It holds the parts below and carries the applied fill. Required.
  • TagFilterTrigger: the filter's name and its optional 14px icon; the button that opens the list. Unset it carries the chevron; applied it doesn't. Required.
  • TagFilterTag: one value, a 24px tag with a 18px ×. One per value shown.
  • TagFilterMore: +N, the values that don't fit. It opens the list as the trigger does.
  • TagFilterClear: the × at the group's end that clears the filter, after a 1px seam. The seam is as far from what comes before it, a tag's edge or +N's text, as from the × after it. Only with clearable.
  • The list: the combobox popup, anchored to the group's start. A header with the filter's name and Clear, an optional search, and the values with a check on each chosen one, in groups when groups is given.

ComboboxTagFilter puts these together over a multiple Combobox; use the parts yourself only for a structure it doesn't cover.

Options

  • maxTagCount: how many tags show.
    • "responsive" (default): as many as fit the group's room, then +N. The group is at most 320px wide, or what its parent gives it if less (outside a FitToolbar, which measures the room itself); set a max-w-* on it for another cap.
    • A number: at most that many, then +N.
    • "none": every tag, and the group wraps onto more lines. Use it only where the toolbar can grow taller.
  • clearable (default true): the × at the group's end. Leave it on: clearing a filter of several values one tag at a time is slow. Turn it off only when the filter can't be empty.
  • search: a search row at the top of the list, for a list that can hold many values (people, places). With it, give emptyLabel. Opened with a mouse or the keyboard, typing goes straight to it, and Enter takes the first match; opened by a tap, it takes no focus, so the keyboard doesn't come up over the list. A list of a few fixed values (statuses, outcomes) has none.
  • searchTextOf: what the search matches for a value, labelOf by default. Give people their display name and handle, so a search for either finds them; give a "Me" row its own word with the person's name and handle, so a search for yourself finds it.
  • disabled: the filter can't open yet, while its values load: the trigger takes PickerTriggerButton's disabled look. An empty list that opens is more confusing than a button that waits.
  • popupClassName: the list's width, 240px (w-60) by default. Widen it for long names, such as a computer by code and name.
  • groups, instead of items: the list in groups, each { label?, items }. A group's values sit under its heading (ComboboxGroupLabel), with a separator between groups; a group without a label shows no heading. The type takes one or the other, never both. When the search leaves a group with nothing, its heading and the separator before it go too, so no line is left on its own.
  • tagLabelOf: a shorter text for a value inside its tag alone, such as a computer's code. Everything else keeps labelOf's full name: the tag's title, its ×'s name, the trigger's name and tooltip, and the search. The ruler measures the short text, since that is what the tag shows.
  • open and onOpenChange: the list's open state, for a page that keeps one filter's list open at a time. Uncontrolled by default.
  • tagsOrder and labelOrder: its steps in a FitToolbar (below).
tag-filter/compositions/groups

In a FitToolbar

An applied filter marks itself data-active, as FitToolbar asks of an applied item, so a scrolling group keeps it in view; the caller adds nothing.

In a FitToolbar the filter gives way with the rest of the toolbar (FitToolbar › Behavior). It doesn't measure its parent's room there: the toolbar does, and two measures of one room would disagree, as SegmentedControl's iconsOnlyBelow is off in a toolbar. It shows every tag the 320px cap holds, and folds into +N within that cap only.

  • tagsOrder (the tags step): its tags fold to the first one and +N, at least one tag kept.
  • labelOrder (the label step): its name hides and its icon stays. The trigger's accessible name and a tooltip keep the name and every value (valueLabel). A filter without an icon refuses this step, since nothing would be left to show.

Its trigger and, once it is applied, its clear × are the toolbar's items: one or two per filter. The toolbar stays one Tab stop, and its arrow keys go through them in reading order, the trigger, then its clear ×, then the next item; an unset filter is its trigger alone. A tag's × is for a pointer and never a stop. After the clear × takes the filter's values out, focus goes to the trigger, which then holds the toolbar's Tab stop. An item the arrow keys reach under a scrolling group's fade comes into view. Before, the trigger and the clear × were Tab stops of their own inside the toolbar, and its arrow keys didn't reach them (slock's Tasks and search toolbars).

A filter never moves into More: as The toolbar over a list says, the filters wrap to a line of their own that scrolls sideways. Put them in a FitToolbarGroup with overflow="scroll" in a toolbar with wrap, the sort on the first line.

Give tags and label the numbers of The toolbar over a list: a filter's own tags fold first, then its name becomes its icon. At the same number tags comes before label, and the filters of one FitToolbarGroup with the same number fold and unfold together. Items in a FitToolbar don't shrink; truncation happens only within the 320px cap, the tag first, then the name (0.111.2's rule).

tag-filter/compositions/in-fit-toolbar

States

  • Unset: the PickerTriggerButton look, the name and a chevron, as high as the other filter buttons.
  • Applied: the group fills info-soft at the same height. The name inside it has no fill of its own; it hovers with the medium overlay (Hover and press).
  • A tag sits on the canvas colour with a seam ring. Its × is 18px, 3px from the tag's top, bottom and end, so its hover fill stays inside the tag; only the × hovers.
  • The clear × is 24px with a 14px glyph, 4px from the group's end; it hovers with the medium fill.

Behavior

  • Choosing a value in the list adds its tag at the end; tags keep the order the values were chosen in. The list stays open while people choose.
  • A tag's × takes that one value out. The clear × takes them all out, and the filter is unset again.
  • After a × removes itself, focus goes to the trigger, never to the page or to the next filter. The trigger's new name says what is left.
  • With maxTagCount="responsive", tags fold into +N before the name is cut, and one tag always shows. When even that one doesn't fit beside the name, the tag gives way first: its label truncates down to a letter, an ellipsis and its ×, and only then the name truncates, so the filter keeps saying what it is ("Destinations [Private c… ×] +2" in a 280px column). The count is measured before the first paint and again when the row resizes, so no frame shows tags that are then taken back.
  • On a touch screen, each × and +N has a hit area of at least 24px; +N counts as part of the trigger (Accessibility › Hit targets).

Content

  • Name the filter by what it filters, as a noun: Status, Assignee, Channel. Don't add the word Filter.
  • A tag says the value's name as the list does, or a short form of it through tagLabelOf (a computer's code) when the full name would crowd the toolbar. Keep the icon in the list; the tag carries text only.
  • A shortcut for the person viewing ("Me") is a plain first row, in an unlabelled first group followed by the separator, then the labelled People group. Its tag says the shortcut's own word (labelOf returns "Me"), never expanded to the person's name. Leave the person out of the People group, so the same person can't be two values and two tags.
  • Name a tag's × "Remove {value}", and the clear × "Clear {filter}": the clear ×'s name always says which filter it clears.
  • The caller writes every sentence, in its own language: the trigger's name once values are chosen (valueLabel, from the labels in order), each tag's × (removeLabel) and the clear × (clearFilterLabel). TagFilter joins no words itself, so a list takes the language's own mark: "Assignee: Kirby, Tenny" in English, the ideographic comma in Chinese (Intl.ListFormat, or the catalog's list pattern).

Accessibility

  • The group is a role="group" named by the filter; the trigger, the tags' × and the clear × are siblings in it, not nested buttons.
  • Two Tab stops per filter: the trigger and the clear ×. A tag's × is for a pointer (tabIndex=-1); the keyboard takes a value out by unticking it in the list. In a FitToolbar the trigger and the clear × are toolbar items instead, reached with the arrow keys, and the whole toolbar is one Tab stop (In a FitToolbar).
  • The clear × is named by clearFilterLabel, which must name the filter ("Clear Assignee", not "Clear"): in a toolbar of several filters, the arrow keys reach one clear × after another, and a screen reader reads only that name.
  • The trigger's name and tooltip list every chosen value, the folded ones included ("Assignee: Kirby, Tenny, Lagoon, Scout"); unset, it is the filter's name. +N is hidden from screen readers, since the trigger already names those values.
  • No live region: when the filter clears, focus is on the trigger, and its new name is what a screen reader reads.

Rules

  • Use TagFilter for every filter of several values in a toolbar, so all of them read the same way. Don't summarise chosen values as "2 statuses" in the button.
  • Keep a filter of one value a PickerTriggerButton: a tag for a single value with no siblings adds nothing.
  • Don't put a tag's icon, avatar or colour in the tag. The list shows them; the toolbar stays text.
  • Don't nest one filter's group inside another's, or put other controls inside the group.

API

ComboboxTagFilter

ExperimentalThe ready-made filter: TagFilter's parts over a `multiple` Combobox, with `maxTagCount` and `clearable`.
PropTypeDefault
clearableA × at the group's end that clears the filter.booleantrue
clearFilterLabel (required)Names the clear ×: "Clear Assignee".string
clearLabel (required)What the list's Clear button says: "Clear".string
disabledThe filter can't be opened yet (its values are still loading): the trigger takes PickerTriggerButton's disabled look.booleanfalse
emptyLabelThe list's empty state, with a search.string
groupsThe list in groups, instead of `items`: each group's values under its heading, a separator between groups. A group the search empties hides with its heading and its separator.readonly ComboboxTagFilterGroup<Value>[]
iconA leading icon, 14px, `data-icon="inline-start"`. In a FitToolbar, what stays once the name gives way (`labelOrder`).ReactNode
itemsEvery value, in the list's order.readonly Value[]
labelOf (required)A value's name, in the list, the search, the trigger's name and each tag's × and title.(value: Value) => string
labelOrderIn a FitToolbar: when its name gives way to its icon (the `label` step); the trigger's name and tooltip keep the name and every value. Needs an `icon`.number
maxTagCount`"responsive"` (default): as many tags as fit, then +N. A number: at most that many. None: every tag, and the group wraps.number | "none" | "responsive""responsive"
name (required)The filter's name: what the button says unset, the list's title and the group's name.string
onOpenChange(open: boolean) => void
onValueChange (required)(value: Value[]) => void
openThe list is open: with `onOpenChange`, the page keeps one filter's list open at a time. Uncontrolled by default.boolean
popupClassNameThe list's width, `w-60` (240px) by default: wider for long names ("w-70" for computers by code and name).string
removeLabel (required)Names a tag's ×: (label) => "Remove {label}".(label: string) => string
renderItemA row of the list; its name by default.(value: Value) => ReactNode
searchA search row in the list, for a list that can hold many values (people, places).{ label: string; placeholder: string; }
searchTextOfWhat the search matches for a value, `labelOf` by default: a person's display name and handle ("Kirby kirby"), or a "Me" row's own word with the person's name and handle, so searching for yourself finds it.(value: Value) => string
tagLabelOfA shorter text for a value inside its tag alone (a computer's code). The tag's title, its ×'s name, the trigger's name and tooltip and the search keep `labelOf`'s full name. `labelOf` by default.(value: Value) => string
tagsOrderIn a FitToolbar: when its tags fold to the first one and +N (the `tags` step).number
testIdstring
value (required)Value[]
valueLabel (required)The trigger's name and tooltip once values are chosen, from their labels in order: "Assignee: Kirby, Tenny" (in Chinese, with the ideographic comma). The caller writes the sentence, in its language and with its list mark (Intl.ListFormat or the catalog); unset the trigger's name is `name`.(labels: readonly string[]) => string

TagFilter

ExperimentalThe filter's group: the trigger, the tags, +N and the clear ×. Inside a `Combobox` with `multiple`.
PropTypeDefault
name (required)The filter's name: the group's accessible name.string
wrapTags that don't fit wrap onto more lines (no `maxTagCount`), instead of folding into +N.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

TagFilterClear

Experimental`clearable`: the × at the group's end that clears the whole filter. A Tab stop, or in a FitToolbar one of its items; focus then goes to the trigger.
PropTypeDefault
disabledWhether the component should ignore user interaction.booleanfalse
keepMountedWhether the component should remain mounted in the DOM when not visible.booleanfalse
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

TagFilterMore

Experimental`+N`: the tags that don't fit. It opens the list as the trigger does; hidden from screen readers, whose trigger names every value.
PropTypeDefault
count (required)number

Also takes the attributes of its element.

TagFilterTag

ExperimentalOne value: a 24px ComboboxChip with its ×, for a pointer only (the keyboard unticks it in the list).
PropTypeDefault
removeLabel (required)Names the tag's ×: "Remove Codex".string
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

TagFilterTrigger

ExperimentalThe filter's name, the button that opens the list. Unset it carries the chevron.
PropTypeDefault
valueLabelThe trigger's accessible name: the filter's name unset ("Runtime"), with every chosen value applied ("Runtime: Claude Code, Codex"), which is also its tooltip. A combobox takes no name from its text, so pass it unset too.string
disabledWhether the component should ignore user interaction.booleanfalse
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.