Choice Box
A larger, more descriptive version of a radio or checkbox, with a generous tap target and room for supporting details, enhancing usability and clarity.
Installation
Install the component via the CLI in one command.
npx shadcn@latest add @intentui/choice-box
Composed components
When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.
Manual installation
Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.
npm install react-aria-components @heroicons/react
Anatomy
import {
Choicebox,
ChoiceboxDescription,
ChoiceboxItem,
ChoiceboxLabel,
} from "@/components/ui/choicebox"<Choicebox aria-label="Select items" selectionMode="multiple">
<ChoiceboxItem textValue="premium">
<ChoiceboxLabel>Premium</ChoiceboxLabel>
<ChoiceboxDescription>
Advanced options for growing needs.
</ChoiceboxDescription>
</ChoiceboxItem>
<ChoiceboxItem textValue="deluxe">
<ChoiceboxLabel>Deluxe</ChoiceboxLabel>
<ChoiceboxDescription>
Top-tier features for maximum performance.
</ChoiceboxDescription>
</ChoiceboxItem>
<ChoiceboxItem textValue="ultimate">
<ChoiceboxLabel>Ultimate</ChoiceboxLabel>
<ChoiceboxDescription>
All-inclusive plan with every feature available.
</ChoiceboxDescription>
</ChoiceboxItem>
<ChoiceboxItem textValue="enterprise">
<ChoiceboxLabel>Enterprise</ChoiceboxLabel>
<ChoiceboxDescription>
Customized solutions for large organizations.
</ChoiceboxDescription>
</ChoiceboxItem>
</Choicebox>Examples
Multiple selection
By default, it uses single selection mode. To allow multiple selections, set the selectionMode prop to 'multiple'. This enables users to select more than one item at a time.
Columns and gap
By default, the gap between items is set to 0, and the columns prop is also 0. You can customize both by providing your own gap and columns values.
Icons
You can add icons to the Choicebox items by providing the icon prop.
Controlled
This component can function as either controlled or uncontrolled. For controlled use, provide the selectedKeys prop and manage updates with the onSelectionChange event handler.
Disabled
Disable the entire Choicebox by applying the isDisabled prop.
Individual items can also be disabled by specifying their keys in the disabledKeys prop.
<Choicebox disabledKeys={['sm', 'lg']} />Component API
ChoiceBox
The ChoiceBox component displays selectable options in a boxed layout.
| Prop | Type | Default |
|---|---|---|
className | string | - |
columns | "1" | "2" | "3" | "4" | "5" | "6" | 1 |
gap | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "8" | "10" | "12" | 0 |
isReadOnly | boolean | - |
ChoiceBoxDescription
The ChoiceBoxDescription component renders supporting text for a choice item.
| Prop | Type | Default |
|---|---|---|
className | string | - |
ChoiceBoxItem
The ChoiceBoxItem component represents one selectable choice.
| Prop | Type | Default |
|---|---|---|
className | string | - |
description | string | - |
label | string | - |
ChoiceBoxLabel
The ChoiceBoxLabel component renders the label for a choice item.
| Prop | Type | Default |
|---|---|---|
className | string | - |
See the React Aria for the full API reference.
Unlock the full power ofIntent UI Design
Build modern web apps faster with 1000+ resources across components, blocks, patterns, templates, and starter kits.