Chip
A compact pill for a filter, a choice or an entered value: selectable as a toggle, removable with a button or the keyboard.
c2-chip
Compact pill for a filter, a choice or an entered value: the chip of Material, Mantine and antd. A plain chip is a
read-only label. selectable turns it into a toggle button (aria-pressed) that flips selected on click, Enter
or Space and fires change, with a check mark while selected. removable adds a remove button that fires
remove; Backspace or Delete on a selectable chip does the same. The chip never removes itself: the application
drops it from its own list in the remove handler, so framework-rendered lists stay in sync. c2-badge stays the
non-interactive status label; use a chip when people pick or dismiss it.
A chip can also read as a sentence made of c2-chip-part children (Status | is any of | Active), each of which can
be its own button: that is the filter chip of Linear and Airtable. Left and Right arrows then move between the
interactive parts and the remove button, and Backspace or Delete on a part fires remove. Importing the chip
registers c2-chip-part too. A chip with parts is never a toggle, even with selectable.
<c2-chip removable>
<c2-chip-part name="field">Status</c2-chip-part>
<c2-chip-part name="operator" interactive>is any of</c2-chip-part>
<c2-chip-part name="value" interactive>Active, Paused</c2-chip-part>
</c2-chip>
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
selectable | boolean | false | Makes the chip a toggle button that flips selected and fires change. |
selected | boolean | false | Selected state of a selectable chip. Ignored by a plain chip. |
removable | boolean | false | Adds a remove button. Its click, or Backspace/Delete on a selectable chip, fires remove. |
disabled | boolean | false | Disables toggling and removal, and dims the chip. |
value | string | — | Stable identity of the chip, handed back in the remove event. Defaults to the chip's text. |
remove-label | string | Remove | Accessible name of the remove button, followed by the chip's text: Remove Design. |
Slots
| Name | Description |
|---|---|
(default) | Chip label, or two or more c2-chip-part segments. |
prefix | Icon or avatar shown before the label. |
selected-icon | Mark shown before the label while a selectable chip is selected. Defaults to a check mark. |
remove-icon | Icon of the remove button. Defaults to a cross. |
Events
| Name | Type | Description |
|---|---|---|
remove | CustomEvent | The remove button, Backspace or Delete was used. detail.value is the chip's value (or its text). Remove the chip in the handler. |
change | A selectable chip was toggled by the user. Read selected on the target. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
chip | The visible pill around the label and the remove button. |
action | The toggle <button> of a selectable chip, or the label wrapper of a plain one. It contains the default slot (the label) along with the prefix and the selected mark. |
remove-button | The remove <button>. It wraps the remove-icon slot, whose cross fallback is replaced by any assigned icon. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-chip__container--height | pixel | 28px | |
--c2-chip__container--padding-left | padding | 10px | |
--c2-chip__container--padding-right | padding | 10px | |
--c2-chip__container--gap | pixel | 6px | Space between the icon, the label and the remove button. |
--c2-chip__container--border-radius | border-radius | 999px | |
--c2-chip__container--border | border | 1px solid #bcbcc6 | |
--c2-chip__container--background-color | color | #ffffff | |
--c2-chip__container--color | color | #18181b | |
--c2-chip__container--font-family | font-family | inherit | |
--c2-chip__container--font-size | pixel | 14px | |
--c2-chip__container--font-weight | font-weight | 500 | |
--c2-chip__container__hover--border | border | 1px solid #a1a1aa | Hover border of a selectable chip. |
--c2-chip__container__hover--background-color | color | #f4f4f5 | Hover background of a selectable chip. |
--c2-chip__container__selected--border | border | 1px solid transparent | |
--c2-chip__container__selected--background-color | color | #edf1fe | |
--c2-chip__container__selected--color | color | #0265dc | |
--c2-chip__container__selected__hover--background-color | color | — | Hover background of a selected chip. Defaults to the selected background. |
--c2-chip__container__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-chip__container__focus--outline-offset | pixel | 2px | |
--c2-chip__container__disabled--opacity | opacity | 0.38 | |
--c2-chip__icon--size | pixel | 16px | Size of the prefix and selected-icon content. |
--c2-chip__icon--color | color | — | Colour of the prefix and selected-icon content. Defaults to the text colour. |
--c2-chip__selected-icon--display | display | inline-flex | none hides the check mark and relies on the colours alone. |
--c2-chip__remove-button--size | pixel | 18px | |
--c2-chip__remove-button--margin-right | pixel | -4px | Pulls the remove button towards the edge so the padding looks even. |
--c2-chip__remove-button--border-radius | border-radius | 999px | |
--c2-chip__remove-button--color | color | #71717a | |
--c2-chip__remove-button__hover--background-color | color | rgba(24, 24, 27, 0.08) | |
--c2-chip__remove-button__hover--color | color | #18181b | |
c2-chip-part
One segment of a c2-chip, for chips that read as a sentence: Status | is any of | Active. Put two or more in a
chip's default slot; the chip draws them side by side with a divider between them. A plain part is text. An
interactive part is a button that fires part-click with its name, so each segment can open its own editor;
the event bubbles, so one listener on the chip serves every part. Left and Right arrows move between a chip's
interactive parts and its remove button.
A chip whose parts are interactive is not selectable: a toggle cannot contain buttons.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
name | string | — | Identity of the part, handed back in part-click: field, operator, value. |
interactive | boolean | false | Renders the part as a button that fires part-click. |
disabled | boolean | false | Disables an interactive part. |
label | string | — | Accessible name of an interactive part when its text alone is unclear, e.g. Status filter: change operator. |
haspopup | ChipPartPopup | — | Kind of popup an interactive part opens, exposed as aria-haspopup. Empty for none. |
expanded | boolean | undefined | undefined | Whether the popup an interactive part opens is showing, exposed as aria-expanded. Unset for none. |
Slots
| Name | Description |
|---|---|
(default) | Text of the part. |
prefix | Icon, colour dot or avatar shown before the text. |
Events
| Name | Type | Description |
|---|---|---|
part-click | CustomEvent<ChipPartClickDetail> | An interactive part was clicked, or activated with Enter or Space. detail.name is the part's name; the event target is the part, to anchor a popover on. Bubbles. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
part | The <button> of an interactive part, or the wrapper of a plain one. It contains the default slot (the text) after the prefix slot. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-chip-part__container--padding-left | padding | 8px | |
--c2-chip-part__container--padding-right | padding | 8px | |
--c2-chip-part__container--gap | pixel | 6px | Space between the prefix and the text. |
--c2-chip-part__container--border-left | border | 1px solid #e4e4e7 | Divider drawn before every part but the first. |
--c2-chip-part__container--color | color | inherit | Text colour. Inherits the chip's. |
--c2-chip-part__container--font-weight | font-weight | inherit | |
--c2-chip-part__container__first--padding-left | padding | 10px | Left padding of the first part, matching the chip's own padding. |
--c2-chip-part__container__hover--background-color | color | rgba(24, 24, 27, 0.08) | Background of an interactive part on hover and while its popup is expanded. |
--c2-chip-part__container__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-chip-part__container__focus--outline-offset | pixel | -2px | Negative, so the ring stays inside the pill. |
--c2-chip-part__container__disabled--opacity | opacity | 0.38 | |
--c2-chip-part__icon--size | pixel | 16px | Size of an SVG in the prefix slot. |