Live demo
Demo source
Pills are interactive: people select them to filter a list or choose options. To label content, use a tag; to show a non-interactive status, use a status indicator.
Anatomy
A selected pill with a light-bulb icon, the label Label and a check mark. Callout 1 marks the container, 2 the leading icon, 3 the label and 4 the check mark.
- Container with rounded edges; its border and fill show the state.
- Leading icon (optional), set with
leadingIconor theleading-iconslot. - Label names the option; set it with
label. - Check mark appears while the pill is
selected.
States and selection
Pills have default, hover, selected and disabled states and no colour variants.
Clicking a pill or pressing Enter or Space toggles selected and emits
toggled. As direct children of an element with role="radiogroup", pills with
pillAriaRole="radio" allow one choice and support the arrow keys.
The whole pill is the interaction target. Its neutral base and brand-coloured hover and selected states communicate behaviour; do not assign category colours or override the state colours. Keep the label visible, because it also provides the accessible name.
The design's active or selected appearance maps to selected; the component
does not have an active prop.
Guidelines
- Use pills to turn filters on and off or to choose from a short list.
- Keep labels short and action- or option-oriented.
- Do not use pills for static categories or system status.
Use several pills for independent filters or multiple attributes, and radio
semantics when only one option is allowed. The design also suggests compact
secondary actions: handle toggled to respond to the choice. If the action
should not leave a selected state, use a button.