Choicebox
チョイスボックス
A radio group rendered as full width cards, each with a title, a subtitle and a description. Built with Base UI↗↗ and Tailwind CSS.
Installation
Install the following dependencies:1
npm install @base-ui-components/reactCopy and paste the following code into a new component file:2
How to use it3
Props
Choicebox
| Name | Default | Description |
|---|---|---|
| children | — | ReactNode ChoiceboxItem cards |
| value | — | string Controlled selected value, pair it with onValueChange |
| defaultValue | — | string Initially selected value when uncontrolled |
| onValueChange | — | (value: string) => void Called with the value of the picked item |
| className | — | string Additional classes on the group |
ChoiceboxItem
| Name | Default | Description |
|---|---|---|
| value | — | string Value reported to the group when picked |
| children | — | ReactNode A header and an indicator |
| className | — | string Additional classes on the card |
ChoiceboxItemHeader
| Name | Default | Description |
|---|---|---|
| children | — | ReactNode Title, subtitle and description |
| className | — | string Additional classes on the text column |
ChoiceboxItemTitle
| Name | Default | Description |
|---|---|---|
| children | — | ReactNode Name of the option, can wrap a subtitle |
| className | — | string Additional classes on the title |
ChoiceboxItemSubtitle
| Name | Default | Description |
|---|---|---|
| children | — | ReactNode Muted text sitting next to the title |
| className | — | string Additional classes on the subtitle |
ChoiceboxItemDescription
| Name | Default | Description |
|---|---|---|
| children | — | ReactNode Supporting copy below the title |
| className | — | string Additional classes on the description |
ChoiceboxIndicator
| Name | Default | Description |
|---|---|---|
| className | — | string Additional classes on the radio, its value comes from the parent item |