Skip to main content

Components

Chip

Chip are small, interactive components that allow users to control how they want to see content. For example, they can be used to filter categories in a search result and show which filters are active.

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

ChipRemovable

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

ChipCheckbox

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

ChipRadio

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

Usage

Examples

Chip.Checkbox

Chip.Removable

Remember aria-label if the contents of Chip do not explain that it can be removed.

Chip.Button

HTML

Chip uses two different HTML structures, but both have the class name ds-chip.

Like radio or checkbox

Notice that we put <input> inside <label>, this means you don't need to connect them with for and id.

As removable or button

A removable Chip uses a <button> element, but data-removable="true" has been added to indicate that it is a removable Chip. Then a cross will appear to the right of Chip, this is drawn with CSS.

CSS variables and data attributes

Chip also uses ds-input internally when it is a radio or checkbox.

CSS Variables
NameValue
--dsc-chip-backgroundvar(--ds-color-surface-tinted)
--dsc-chip-background--hovervar(--ds-color-surface-hover)
--dsc-chip-background--activevar(--ds-color-surface-active)
--dsc-chip-background--checkedvar(--ds-color-base-default)
--dsc-chip-background--checked--hovervar(--ds-color-base-hover)
--dsc-chip-background--checked--activevar(--ds-color-base-active)
--dsc-chip-border-widthvar(--ds-border-width-default)
--dsc-chip-border-stylesolid
--dsc-chip-border-colorvar(--ds-color-border-subtle)
--dsc-chip-border-color--checkedtransparent
--dsc-chip-colorvar(--ds-color-text-default)
--dsc-chip-input-accent-colorvar(--ds-color-base-contrast-default)
--dsc-chip-input-colorvar(--ds-color-text-subtle)
--dsc-chip-input-stroke-colorvar(--ds-color-base-default)
--dsc-chip-border-radiusvar(--ds-border-radius-full)
--dsc-chip-border-radius--checkboxvar(--ds-border-radius-md)
--dsc-chip-border-radius--checkbox-inputvar(--ds-border-radius-sm)
--dsc-chip-heightvar(--ds-size-8)
--dsc-chip-icon-sizevar(--ds-size-7)
--dsc-chip-icon-urlurl("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' fill='none' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M6.53 5.47a.75.75 0 0 0-1.06 1.06L10.94 12l-5.47 5.47a.75.75 0 1 0 1.06 1.06L12 13.06l5.47 5.47a.75.75 0 1 0 1.06-1.06L13.06 12l5.47-5.47a.75.75 0 0 0-1.06-1.06L12 10.94z'/%3E%3C/svg%3E")
--dsc-chip-input-sizevar(--ds-size-5)
--dsc-chip-spacingcalc((var(--dsc-chip-height) - var(--dsc-chip-input-size))/2)
--dsc-input-backgroundtransparent
--dsc-input-border-colorvar(--dsc-chip-input-color)
--dsc-input-accent-colorvar(--dsc-chip-input-accent-color)
--dsc-input-stroke-colorvar(--dsc-chip-input-stroke-color)
--dsc-input-size--togglevar(--dsc-chip-input-size)
--dsc-input-outline-width--hover0
Data Attributes
NameValue
data-removable
Edit this page on github.com (opens in a new tab)