Chip
Selectable or dismissible tag component for filters, categories, and selections. Powered by Alpine.js for interactive functionality.
Variants
Chips come in three variants: primary, secondary, and ghost (default).
Selected State
Chips can be in a selected state, which changes their appearance to indicate active selection.
Unselected
Selected
With Icons
Chips can include optional leading icons for additional context.
Dismissible Chips
Chips can be dismissible with an X button. Click the X to remove the chip (powered by Alpine.js).
Note: Refresh the page to restore dismissed chips.
Disabled State
Disabled chips cannot be interacted with.
Use Case: Filter Chips
Chips are ideal for filter interfaces where users can select multiple options.
Risk Level Filters
Location Filters
Use Case: Category Tags
Chips work well for displaying and managing categories or tags.
Interactive Example
Click chips to toggle selection. This demonstrates how chips can be used in a real application.
Accessibility
- Uses
role="button"for proper semantics - Includes
aria-pressedto indicate selected state - Includes
aria-disabledfor disabled chips - Keyboard accessible with
tabindex="0" - Focus visible ring for keyboard navigation
- Dismissible chips have separate accessible close button
- Smooth transitions are trauma-informed (not jarring)
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| selected | boolean | false | Selected state |
| disabled | boolean | false | Disabled state |
| icon | string | null | Optional leading icon name |
| dismissible | boolean | false | Show X icon to clear (Alpine.js) |
| variant | string | 'ghost' | primary, secondary, ghost |
| class | string | '' | Additional CSS classes |
Usage Example
<x-building-blocks.chip>
Filter Option
</x-building-blocks.chip>
<x-building-blocks.chip variant="primary" :selected="true" icon="check">
Active Filter
</x-building-blocks.chip>
<x-building-blocks.chip :dismissible="true" icon="location">
Brazil
</x-building-blocks.chip>
<div x-data="{ selected: false }">
<x-building-blocks.chip
@click="selected = !selected"
:selected="selected"
>
Toggle Me
</x-building-blocks.chip>
</div>