Radio Group
A set of mutually exclusive radio buttons where only one can be selected at a time.
Install
Pull Radio Group from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { RadioGroup } from "@brika/clay";import { RadioGroup } from "@brika/clay/components/radio-group";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
'use client';
import { Label } from '@brika/clay/components/label';
import { RadioGroup, RadioGroupItem } from '@brika/clay/components/radio-group';
/** Vertical radio group with a default value pre-selected. */
export default function RadioGroupDefaultDemo() {
return (
<RadioGroup defaultValue="comfortable">
<div className="flex items-center gap-2">
<RadioGroupItem value="default" id="r1" />
<Label htmlFor="r1">Default</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="comfortable" id="r2" />
<Label htmlFor="r2">Comfortable</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="compact" id="r3" />
<Label htmlFor="r3">Compact</Label>
</div>
</RadioGroup>
);
}Radio Group, every way
Accessibility
- Arrow keys move selection within the group, Tab leaves the group entirely.
- Always pair items with visible
<Label htmlFor={id}>elements. - Disabled individual items carry
aria-disabledand are skipped by arrow keys. - Use
defaultValuefor uncontrolled initial selection;value+onValueChangefor controlled.
Theme tokens
Every CSS variable Radio Group reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Radio Group
without touching component code.
Radio Group tokens
13 tokens--radio-group-unchecked-containercolorvar(--input-container)components.radioGroup.uncheckedContainerDisc background in the resting (unchecked) state.
--radio-group-unchecked-bordercolorvar(--input-border)components.radioGroup.uncheckedBorderDisc border color in the resting (unchecked) state.
--radio-group-checked-containercolorvar(--primary)components.radioGroup.checkedContainerDisc background when selected (`data-[state=checked]`).
--radio-group-checked-bordercolorvar(--primary)components.radioGroup.checkedBorderDisc border color when selected.
--radio-group-indicator-colorcolorvar(--primary-foreground)components.radioGroup.indicatorColorColor of the inner dot painted on the selected disc.
--radio-group-invalid-bordercolorvar(--destructive)components.radioGroup.invalidBorderDisc border color when the radio has `aria-invalid="true"`. Defaults to the theme destructive hue.
--radio-group-invalid-ringcolorvar(--destructive)components.radioGroup.invalidRingColor of the invalid-state focus halo. Painted at 20% opacity in light mode, 40% in dark mode for parity with other form controls.
--radio-group-sizesize1remcomponents.radioGroup.sizeRadio button diameter.
--radio-group-radiusradius9999pxcomponents.radioGroup.radiusRadio button border radius.
--radio-group-border-widthborder-width1pxcomponents.radioGroup.borderWidthBorder width on the radio-group. Set non-zero for outline-style variants.
--radio-group-border-styleborder-stylesolidcomponents.radioGroup.borderStyleBorder style on the radio-group (`solid`, `dashed`, `double`, `none`).
--radio-group-durationdurationvar(--motion-standard-duration)components.radioGroup.durationTransition duration for radio-group state changes.
--radio-group-easingeasingvar(--motion-standard-easing)components.radioGroup.easingTransition easing for radio-group state changes.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.radioGroup, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"radioGroup": {
"radius": "9999px"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-radio-group-…) — see the
chips on each token row.
API reference
Props specific to Radio Group. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<RadioGroup />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<RadioGroupItem />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.