Selectable Pill
A pill-shaped button component that can be toggled between selected and unselected states with visual feedback.
Basic usage
Different sizes
Disabled state
Filter/tag example
Installation
Install the following dependencies
Loading...
API Reference
Props list
| Prop | Type | Default | Example | Description |
|---|---|---|---|---|
selected | boolean | false | true | Whether the pill is in the selected state. When selected, the pill uses primary colors with shadow. When unselected, it uses muted colors with hover effects. |
size | "sm" | "default" | "lg" | "default" | sm | The size of the pill. Small uses px-2.5 py-1, default uses px-3 py-1.5, and large uses px-4 py-2. |
children | ReactNode | - | Pill Text | The content to display inside the pill button. |
className | string | - | custom-class | Additional CSS classes to apply to the pill element. |
Behavior
The component provides visual feedback based on the selected state:
- When
selectedisfalse, the pill uses muted background and text colors with a hover effect that slightly darkens the background. - When
selectedistrue, the pill uses primary background and foreground colors with a shadow for emphasis. - The component includes smooth transitions between states with a 200ms duration.
- All standard button props are supported through spread props, allowing full customization of button behavior (onClick, disabled, etc.).
- The pill shape is achieved using
rounded-full, making it ideal for tags, filters, and selection UI patterns.