npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-choice-group.json --yesChoice group
ProA form's question answered by ticking boxes or picking one described option, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- ChoiceGroupItemOne choice of a ChoiceGroup
import { ChoiceGroup, ChoiceGroupItem } from '@/components/ui/goop/choice-group';
import { Checkbox } from '@/components/ui/goop/checkbox';
import { RadioGroup, RadioGroupItem } from '@/components/ui/goop/radio-group';
<>
<ChoiceGroup label="What you plan to grow" description="Choose at least one" columns="auto">
<ChoiceGroupItem label="Beans">
<Checkbox name="crops" value="beans" defaultChecked />
</ChoiceGroupItem>
<ChoiceGroupItem label="Herbs">
<Checkbox name="crops" value="herbs" />
</ChoiceGroupItem>
<ChoiceGroupItem label="Flowers">
<Checkbox name="crops" value="flowers" />
</ChoiceGroupItem>
</ChoiceGroup>
<ChoiceGroup label="Plan" error="Choose a plan to continue.">
<RadioGroup name="plan" required>
<ChoiceGroupItem label="Starter" description="Up to three members">
<RadioGroupItem value="starter" />
</ChoiceGroupItem>
<ChoiceGroupItem label="Team" description="Up to twenty members">
<RadioGroupItem value="team" />
</ChoiceGroupItem>
</RadioGroup>
</ChoiceGroup>
</>Answer two questions by tapping anywhere on a row: studies (at least one) and how often (one). Send with either unanswered is refused under that question; answered, it shows what the form sends. Lay the studies in columns, or turn both questions off. Nothing is sent: Send only reads the form.
When to use
- A form's question answered by ticking boxes or picking one described option.
- Use it wherever a form asks a question answered by ticking boxes (interests, days, terms) or by picking one of a few described options (a plan); never a Field round a list of checkboxes. The group checks nothing: a "choose at least one" rule is the form's, its sentence handed to
error. A few short options in a settings row: a Select in a Field.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Choice group on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-choice-group.json --yesAdd the Goop Choice group to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { ChoiceGroup, ChoiceGroupItem } from '@/components/ui/goop/choice-group';
import { Checkbox } from '@/components/ui/goop/checkbox';
import { RadioGroup, RadioGroupItem } from '@/components/ui/goop/radio-group';
<>
<ChoiceGroup label="What you plan to grow" description="Choose at least one" columns="auto">
<ChoiceGroupItem label="Beans">
<Checkbox name="crops" value="beans" defaultChecked />
</ChoiceGroupItem>
<ChoiceGroupItem label="Herbs">
<Checkbox name="crops" value="herbs" />
</ChoiceGroupItem>
<ChoiceGroupItem label="Flowers">
<Checkbox name="crops" value="flowers" />
</ChoiceGroupItem>
</ChoiceGroup>
<ChoiceGroup label="Plan" error="Choose a plan to continue.">
<RadioGroup name="plan" required>
<ChoiceGroupItem label="Starter" description="Up to three members">
<RadioGroupItem value="starter" />
</ChoiceGroupItem>
<ChoiceGroupItem label="Team" description="Up to twenty members">
<RadioGroupItem value="team" />
</ChoiceGroupItem>
</RadioGroup>
</ChoiceGroup>
</>- Fits: flow (its recipe).
- Also known as: CheckboxGroup, Fieldset, ChoiceList, CheckboxList.
- height, width, padding, gap, border, text: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| label | ReactNode | The question the choices answer, the group's name (its legend). |
| description? | ReactNode | A line under the label, read with the group ("Choose all that apply"). |
| error? | ReactNode | What is wrong and how to fix it, once under the rows; it marks every box invalid. |
| errorId? | string | The error line's id, where the caller needs its own; a generated one otherwise. |
| disabled? | boolean = false | Every choice off: none takes the focus, a click or a key, and none is sent with the form. |
| columns? | 1 | 'auto' = 1 | 1, one column; auto, as many columns of 200 px or more as fit, each filled top to bottom. |
| children | ReactNode | The rows: ChoiceGroupItems, or one RadioGroup holding them for a choice of exactly one. |
| Part | What it is |
|---|---|
| ChoiceGroupItem | One choice of a ChoiceGroup; label: ReactNode — The choice's words, which name its box; description?: ReactNode — An optional second line under the words, in the muted ink, read with the box; children: ReactElement<{ className?: string; disabled?: boolean; 'aria-invalid'?: boolean | 'true' | 'false'; 'aria-describedby'?: string; 'aria-label'?: string; 'aria-labelledby'?: string; }> — The row's control: a Checkbox, or a RadioGroupItem inside a RadioGroup; also takes htmlFor?: string |
- data-slot values (to select a part by): choice-group, choice-group-description, choice-group-item, choice-group-item-content, choice-group-item-control, choice-group-item-description, choice-group-item-label, choice-group-label, choice-group-list
Keyboard
| Key | What it does |
|---|---|
| Space | Toggle |
Accessibility
- The part itself answers the keys above.
- focus-visible: the browser's own (:focus-visible): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| disabled | the attribute data-disabled |
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.