Chips
Assist, suggestion, filter and input chips for compact actions and entries, in a chip set.
import { AssistChip, SuggestionChip, FilterChip, InputChip, ChipSet } from '@windmorph/react';Props
AssistChip 20 props
The label.
surface-container-lowat level 1 instead of an outline.Icon before the label (18px). Hidden from assistive tech.
The flat chip's border:
outline-variant, orstrong(outline) for 3:1 contrast where nothing else shows the chip is interactive.Web density,
0to-3: each step takes 4px off the chip's height (32px at 0, 24px at -2 and -3); its touch target stays 48px. Left out, the chip takes the density of the nearestChipSet,ThemeProviderorThemeScope. M3 asks for density to be the reader's choice rather than a default, so prefer setting it there, from a setting.Ref to the root element: the
<button>, or the<a>withhref.Disables the element: it can't be pressed or focused, and shows the disabled style.
The value a submit button sends with its form, under its
name. On a toggle (toggle) it's astringnaming the button in a selection group instead, required to take part in the group's selection.The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
The element rendered: a native
<button>.Renders a link. Navigation goes through React Aria's
RouterProviderwhen one is set.
Classes for each part, by slot.
Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <a> or <button> attribute.
SuggestionChip 19 props
The label.
surface-container-lowat level 1 instead of an outline.Icon before the label (18px). Hidden from assistive tech.
The flat chip's border:
outline-variant, orstrong(outline) for 3:1 contrast where nothing else shows the chip is interactive.Web density,
0to-3: each step takes 4px off the chip's height (32px at 0, 24px at -2 and -3); its touch target stays 48px. Left out, the chip takes the density of the nearestChipSet,ThemeProviderorThemeScope. M3 asks for density to be the reader's choice rather than a default, so prefer setting it there, from a setting.Ref to the root
<button>element.Disables the element: it can't be pressed or focused, and shows the disabled style.
The value a submit button sends with its form, under its
name. On a toggle (toggle) it's astringnaming the button in a selection group instead, required to take part in the group's selection.The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
The element rendered: a native
<button>.
Classes for each part, by slot.
Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <button> attribute.
FilterChip 24 props
The label.
Icon after the label, e.g. a dropdown arrow when the chip opens a menu. Hidden from assistive tech; the whole chip is the control. Not with
onRemove.surface-container-lowat level 1 instead of an outline.Icon before the label (18px). Hidden from assistive tech.
The flat chip's border:
outline-variant, orstrong(outline) for 3:1 contrast where nothing else shows the chip is interactive.Web density,
0to-3: each step takes 4px off the chip's height (32px at 0, 24px at -2 and -3); its touch target stays 48px. Left out, the chip takes the density of the nearestChipSet,ThemeProviderorThemeScope. M3 asks for density to be the reader's choice rather than a default, so prefer setting it there, from a setting.Ref to the root
<button>element.Disables the element: it can't be pressed or focused, and shows the disabled style.
Identifies the button in a selection group; required to take part in its selection.
The element is being dragged (e.g. a card picked up to move it): sets
data-draggedfor the dragged state layer. A consumer's owndata-draggedattribute counts too.Don't move focus to the element on press (set by menu triggers).
Controlled selection. Ignored inside a selection group.
Initial selection when uncontrolled.
Events
Adds a remove button after the label, a second focus stop named "Remove" + the label (M3: for medium and expanded windows). Backspace or Delete on the chip also calls it.
Called with the new selection when the user toggles the button.
Text
Words the chip announces, with English defaults. A
LabelsProvidersets them for the whole app.First word of the remove button's name, which ends with the label.
Announces a selected
InputChipthat has noonPress(with one, its action carriesaria-pressed): the remove button's description, or hidden text on a static chip.
Classes for each part, by slot.
The trailing icon slot (
trailingIcon).The toggle of a chip with a remove button.
The remove button after the label.
The label text.
The row holding the leading icon, label and trailing icon.
The chip's container, merged with
className.The leading icon or avatar slot.
Inline styles for the root element.
Classes for the root element, merged with
classNames.root; consumer classes win.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <button> attribute.
InputChip 14 props
The label.
Icon before the label (18px). Hidden from assistive tech.
A 24px image before the label, with 12px corners (takes precedence over
leadingIcon).Shows the chip as selected (
aria-pressedon its action).The flat chip's border.
Web density,
0to-3: each step takes 4px off the chip's height (32px at 0, 24px at -2 and -3); its touch target stays 48px. Left out, the chip takes the density of the nearestChipSet,ThemeProviderorThemeScope. M3 asks for density to be the reader's choice rather than a default, so prefer setting it there, from a setting.Disables the chip's action and its remove button.
Ref to the root element.
Events
The chip's action, e.g. editing the entry. Makes the chip's label part a button.
Shows a remove button; also called on Backspace or Delete.
Text
Words the chip announces, with English defaults. A
LabelsProvidersets them for the whole app.First word of the remove button's name, which ends with the label.
Announces a selected
InputChipthat has noonPress(with one, its action carriesaria-pressed): the remove button's description, or hidden text on a static chip.
Classes for each part, by slot.
The chip's action (a button with
onPress), or its label part.The avatar image before the label.
The remove button after the label.
The chip's container, merged with
className.The row holding the leading icon, label and trailing icon.
The leading icon or avatar slot.
The label text.
Classes for the root element, merged with
classNames.root; consumer classes win.Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ChipSet 15 props
The chips. Filter chips take part in the set's selection with a
value.Filter chip selection:
single(a radio group: selecting a chip clears the others) ormultiple. Withnone, each chip keeps its own state.The selected chips' values (controlled).
The chips selected at first (uncontrolled).
The last selected chip can be deselected, leaving none.
falsekeeps at least one chip selected.Disables every chip in the set, whatever its kind and whether or not the set has a selection. A chip can't opt out, so keep one that must stay usable outside the set.
wraponto new rows, or one row thatscrolls sideways (M3 suggests scrolling past two rows).Web density,
0to-3, for the set and its chips: each step takes 4px off the chips (32px at 0, 24px at -2 and -3) and puts as much more between rows (16px at 0, 24px at -2 and -3), so rows stay 48px apart and every chip keeps a 48px touch target of its own. Left out, the set takes the density of the nearestThemeProviderorThemeScope; M3 asks for density to be the reader's choice, so prefer setting it there.Ref to the root element.
Events
Called with the selected chips' values when the selection changes.
Text
Accessible name for the set of chips. Required unless
aria-labelledbyis set.The id of the element that names the set. Required unless
aria-labelis set.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-assist-chip-container-shape | var(--md-sys-shape-corner-small) | The corners. | AssistChipTokens.ContainerShape |
--md-comp-assist-chip-label-text-color | var(--md-sys-color-on-surface) | The label. | AssistChipTokens.LabelTextColor |
--md-comp-assist-chip-with-icon-icon-color | var(--md-sys-color-primary) | The leading icon. | AssistChipTokens.IconColor |
--md-comp-assist-chip-flat-outline-color | var(--md-sys-color-outline-variant) | The flat chip’s border (the strong outline keeps `outline`). | AssistChipTokens.FlatOutlineColor |
--md-comp-assist-chip-elevated-container-color | var(--md-sys-color-surface-container-low) | The elevated chip’s container. | AssistChipTokens.ElevatedContainerColor |
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-suggestion-chip-container-shape | var(--md-sys-shape-corner-small) | The corners. | SuggestionChipTokens.ContainerShape |
--md-comp-suggestion-chip-label-text-color | var(--md-sys-color-on-surface-variant) | The label. | SuggestionChipTokens.LabelTextColor |
--md-comp-suggestion-chip-with-leading-icon-leading-icon-color | var(--md-sys-color-primary) | The leading icon. | SuggestionChipTokens.LeadingIconColor |
--md-comp-suggestion-chip-flat-outline-color | var(--md-sys-color-outline-variant) | The flat chip’s border (the strong outline keeps `outline`). | SuggestionChipTokens.FlatOutlineColor |
--md-comp-suggestion-chip-elevated-container-color | var(--md-sys-color-surface-container-low) | The elevated chip’s container. | SuggestionChipTokens.ElevatedContainerColor |
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-filter-chip-container-shape | var(--md-sys-shape-corner-small) | The corners. | FilterChipTokens.ContainerShape |
--md-comp-filter-chip-unselected-label-text-color | var(--md-sys-color-on-surface-variant) | The label (and the check), unselected. | FilterChipTokens.UnselectedLabelTextColor |
--md-comp-filter-chip-selected-label-text-color | var(--md-sys-color-on-secondary-container) | The label and the check, selected. | FilterChipTokens.SelectedLabelTextColor |
--md-comp-filter-chip-with-leading-icon-unselected-leading-icon-color | var(--md-sys-color-primary) | The leading icon, unselected. | FilterChipTokens.UnselectedLeadingIconColor |
--md-comp-filter-chip-flat-unselected-outline-color | var(--md-sys-color-outline-variant) | The flat chip’s border, unselected (the strong outline keeps `outline`). | FilterChipTokens.FlatUnselectedOutlineColor |
--md-comp-filter-chip-flat-selected-container-color | var(--md-sys-color-secondary-container) | The flat chip’s container, selected. | FilterChipTokens.FlatSelectedContainerColor |
--md-comp-filter-chip-elevated-unselected-container-color | var(--md-sys-color-surface-container-low) | The elevated chip’s container, unselected. | FilterChipTokens.ElevatedUnselectedContainerColor |
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-input-chip-container-shape | var(--md-sys-shape-corner-small) | The corners. | InputChipTokens.ContainerShape |
--md-comp-input-chip-unselected-label-text-color | var(--md-sys-color-on-surface-variant) | The label (and an unselected leading icon), unselected. | InputChipTokens.UnselectedLabelTextColor |
--md-comp-input-chip-selected-label-text-color | var(--md-sys-color-on-secondary-container) | The label, selected. | InputChipTokens.SelectedLabelTextColor |
--md-comp-input-chip-unselected-outline-color | var(--md-sys-color-outline-variant) | The border, unselected (the strong outline keeps `outline`). | InputChipTokens.UnselectedOutlineColor |
--md-comp-input-chip-selected-container-color | var(--md-sys-color-secondary-container) | The container, selected. | InputChipTokens.SelectedContainerColor |
Spec status
Built to the M3 Expressive chips spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Assist chip | Built | Variant · Assist suggestion |
| Filter chip | Built | Variant · Filter |
| Input chip | Built | Variant · Input |
| Suggestion chip | Built | Variant · Assist suggestion |
| Flat and elevated | Built | Configuration · Assist suggestion |
| Filter content | Built | Use case · Filter |
| Entries a person added | Built | Use case · Input |
| Density (web, chosen by the reader) | Built | Use case · Density |
outline="strong" | Extension | Draws a flat chip's border in outline for 3:1 contrast, as the spec's accessibility guidance asks where nothing else shows the chip's edge. |
ChipSet | Extension | One Tab stop with arrow keys, a shared selection for filter chips, and a scroll layout that keeps one row. |
Assist chip
BuiltVariant · Assist suggestion
Filter chip
BuiltVariant · Filter
Input chip
BuiltVariant · Input
Suggestion chip
BuiltVariant · Assist suggestion
Flat and elevated
BuiltConfiguration · Assist suggestion
Filter content
BuiltUse case · Filter
Entries a person added
BuiltUse case · Input
Density (web, chosen by the reader)
BuiltUse case · Density
Extensionoutline="strong"Draws a flat chip's border in
outlinefor 3:1 contrast, as the spec's accessibility guidance asks where nothing else shows the chip's edge.
ExtensionChipSetOne Tab stop with arrow keys, a shared selection for filter chips, and a
scrolllayout that keeps one row.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
AssistChip,SuggestionChip,FilterChip,InputChip: 20.6 kBChipSet: 13.9 kB
M3 Expressive specs
- Shape
rounded-corner-small- Variants
assist, suggestion, filter, input
Spec values
- 32px tall (a minimum: a chip grows with a large browser font size) with a 48px touch target, 8px corners for every chip type,
label-large, 18px icons, 24px avatars with 12px corners. - 16px at an edge without an icon (12px on an input chip), 8px beside one (4px beside an avatar), 8px between elements and between chips. Padding counts from the chip's edge: a flat chip's 1px border takes none of it, so flat and elevated chips are the same size.
- Elevation never shows a press: an elevated chip rises from level 1 to 2 on hover and a selected flat filter chip from 0 to 1, only while it isn't pressed or keyboard-focused. A keyboard-focused flat chip's border darkens to
on-surface(assist, suggestion) oron-surface-variant(filter, input). - Leading icons are
primary, except a selected filter chip's (on-secondary-container) and an input chip's until it is selected (on-surface-variant). Selected filter and input chips aresecondary-containerwith no border. - The remove button has a 48px target, and a chip with one is at least 88px wide, as M3 asks. Beside a toggle or an action the target is 41px wide: it stops where the label ends, so a press on the label is never taken for the remove button.
- A selected
InputChipwithoutonPresshas noaria-pressedto carry its state, so it says it in words (labels.selected, “Selected”): the remove button's description, or hidden text on a static chip. - Without a leading icon, a selected filter chip grows a check and its start padding moves 16 → 8px.
- Only filter chips take a trailing icon (
trailingIcon); input chips end with their remove button, and assist and suggestion chips have none.