Chip group

Pressable filter pills over native radios or checkboxes, or links. Plain Blade and CSS: no behaviour.

Form control. It takes input in a form, so it is drawn on the Every input type block, beside every other control, as it starts and with an error where it has one.

Anatomy

Status                                   ← legend (or sr-only with hideLabel)
( ✓ Open 12 )  ( Pending 5 )  ( Closed ) ← chips: label > sr-only input + check + icon + words + count
  • Group, input mode: fieldset.min-w-0, legend, then a wrapping flex row of chips. Host attributes land on the fieldset, except the model.
  • Group, link mode: nav[aria-labelledby], a label span, the same row.
  • Chip, input mode: label[data-ds-chip=input], a rounded-full pill, holding input.peer.sr-only (radio, or checkbox posting name[]), the check cell, the optional icon (micro), the words, the optional count.
  • Chip, link mode: a[data-ds-chip=link] with the same children; no href when disabled.
  • Check cell: overflow-hidden, w-0, opening to the icon's width plus a 4px gap (w-5; w-4.5 at sm) when chosen.

How the group reaches the chips

A component's slot renders before the component's own view, so the group cannot pass data down after the fact.

  • name, multiple and size reach the chips through @aware.
  • The group reads the rendered slot: the data-ds-chip markers tell it which mode it is in, and it throws when both are present.
  • Each input carries a data-ds-chip-input hook, which the group replaces with the host's wire:model* / x-model* attributes (or nothing), so the binding lands on every input and the hook never reaches the page.

States

StateTreatment
restingborder-border bg-surface text-fg-body
hoverborder-fg/20 bg-surface-subtle
chosenborder-accent bg-accent-tint text-on-accent-tint, check open
focus-visibleoutline-2 outline-offset-2 outline-focus-ring on the pill (has-focus-visible: for inputs)
disabledbg-surface-subtle text-fg-muted (the muted text of a disabled radio or checkbox label), cursor-not-allowed; chosen and disabled adds border-border-strong, check still open
link activethe chosen look, written out; aria-current="true"

The colour change is motion-safe:transition-colors, the check motion-safe:transition-[width], both duration-popover-enter ease-enter.

Sizes

SizeHeightPaddingTextIcons
sm28pxpx-2.5text-meta14px
md32pxpx-3text-meta16px
lg40pxpx-4text-body16px

Choices and why

  • Pills, not a segmented control. They wrap, each stands alone, and the same look serves one-of and any-of.
  • The input is sr-only, not hidden. It keeps focus, arrow keys and validation; the label carries the look through has-checked:.
  • Mixing modes throws rather than rendering a group half of which posts and half of which navigates.
  • label is required, visible by default; hideLabel keeps it as the name only.

Accessibility

Rolegroup (fieldset) of radios or checkboxes; or navigation of links
NameThe legend, or the nav's label; each chip its words and count
StateNative checked; aria-current="true" on the active link; aria-disabled on a disabled link
KeyboardRadios: arrows move and choose, skipping disabled. Checkboxes: Tab and Space. Links: Tab and Enter
FocusRing on the pill
Not colour aloneThe check
MotionWidth and colour transitions, motion-safe only

Help and error

Since batch 30B, help and error in the one field pattern every control shares (partials/field-message, the markup ds::input draws): the help as muted meta text, or in its place the error with its icon in the danger colour, never both. The message's id ({id}-help, {id}-error) is named by the control's aria-describedby, after anything the host passed. With neither prop the control renders exactly as before (tests/FieldMessagesUnchangedTest.php).

The label is drawn in the field label's style (text-body font-medium text-fg, mb-1.5) since 30B, as every other control's; it was smaller and muted (text-meta text-fg-muted, mb-2). The message describes the fieldset or nav.

Do not

  • Do not use for actions. That is a button.
  • Do not add script. The inputs are the state.
  • Do not put the binding on the chips one by one when the group can carry it; they would drift.

From the package repo: edit this page on GitHub.

Was this page helpful?