<p class="cap-muted">Tab to a chip to see focus. The second chip is shown hovered.</p>
<div class="cap-chips" role="group" aria-labelledby="chips-focus-l">
<span class="cap-chips-label" id="chips-focus-l">Kind</span>
<button type="button" class="cap-chip" aria-pressed="false">Reply</button>
<button type="button" class="cap-chip" aria-pressed="false" id="chip-hover">Link</button>
<button type="button" class="cap-chip" aria-pressed="false">Like</button>
<span class="cap-chips-count" role="status">23 mentions</span>
</div>
An empty result
<div class="cap-chips" role="group" aria-labelledby="chips-empty-l">
<span class="cap-chips-label" id="chips-empty-l">Status</span>
<button type="button" class="cap-chip" aria-pressed="true">Blocked</button>
<button type="button" class="cap-chip" aria-pressed="false">Running</button>
<button type="button" class="cap-chip" aria-pressed="false">Queued</button>
<button type="button" class="cap-link-btn">Clear</button>
<span class="cap-chips-count" role="status">0 of 14 jobs</span>
</div>
<div>
<p id="empty-text">No jobs match "Blocked". 14 jobs are hidden by this filter.</p>
<button type="button" class="cap-btn">Clear filter</button>
</div>
<p class="cap-muted">In an app this is the empty component's no-match kind, which names the filter and offers Clear.</p>
Pressed and hovered, small and large, disabled, with a count and an icon
Called with the pressed values in the options' order. Keep them in the address (writeParam from "capsomer/behavior/chips" makes ?status=blocked,running).
count
ReactNode
Yes
What the filter leaves, in words: "3 of 14 jobs". Announced politely as it changes.
size
"sm" | "default" | "lg"
LinkChips
Prop
Type
Required
Does
label
string
Yes
showLabel
boolean
Show the label before the chips (as FilterChips does); it then names the nav.
A value from the address that no chip carries still shows, pressed, after the last chip. Without it a filter in a shared link would narrow the list with nothing on the page to say so or to release (the Portal's NsChips does the same with a namespace its list does not carry).
setPressed
(group: Element, values: string[]): void
readParam
(search: string, param: string): string[] | null
The values in an address's search string, or null when the parameter is absent.
The address with the parameter set to the values, comma-separated and readable (?status=blocked,running), or removed when there are none. Values must not hold commas.
setCount
(group: Element, text: string): void
Writes the result count into the group's live region: "3 of 14 jobs".
toggle
(group: HTMLElement, chip: HTMLElement): void
Presses or releases one chip, as a click does.
clearAll
(group: HTMLElement): void
Releases every chip, as Clear does. Clear hides itself, so focus goes to the first chip rather than being lost. An empty result's own Clear button calls this too.
enhance
(root?: ParentNode): () => void
Attaches to every [data-cap="chips"] under root that is not attached yet. With data-param, the group reads its starting state from the address and writes it back. Returns a function that detaches them all.
Parts and data attributes
Class
Is
.cap-chip-count
its own class
.cap-chip-input
its own class
.cap-chips
the root
.cap-chips-count
a part
.cap-chips-label
a part
Attribute
Values
data-size
lgsm
data-variant
solid
State
Read from
:checked
the platform
:disabled
the platform
:focus-visible
the platform
:hover
the platform
[aria-current="false"]
an attribute
[aria-current]
an attribute
[aria-disabled="true"]
an attribute
[aria-pressed="true"]
an attribute
Accessibility
Key
Does
Tab
Moves through the chips, then Clear while any is pressed
Enter or Space
Presses or releases a chip; the count and the address follow
Enter on Clear
Releases every chip and moves focus to the first
Arrow keys
Move focus to the next or previous chip without pressing it (wraps)
Home or End
Move focus to the first or last chip
Toggle buttons, not checkboxes: each is a button whose pressed state is read out.
Each chip is at least var(--target) tall; 44 px on a touch screen.
Forced colors: a pressed chip is drawn in Highlight.