PrimitiveAvailable
Radio Group
A mutually exclusive selection controlled with arrow keys.
Installation
Add the component and its dependencies from the registry running on your computer.
terminal
npx shadcn@latest add https://brutallab.facilito.dev/r/radio-group.jsonUsage
Import the component into your project and keep the source code under your control.
tsx
'use client';
import { RadioGroup, RadioGroupItem, RadioCard } from '@/components/ui/radio-group';
import { Label } from '@/components/ui/label';
export default function Demo() {
return (
<div className="grid gap-6"><fieldset className="grid gap-4">
<legend className="mb-4 bl-type-label">Notification frequency</legend>
<RadioGroup defaultValue="daily" aria-label="Notification frequency">
{['Daily', 'Weekly', 'Never'].map((label) => (
<div key={label} className="flex items-center gap-3">
<RadioGroupItem
id={`frequency-${label}`}
value={label.toLowerCase()}
/>
<Label htmlFor={`frequency-${label}`}>{label}</Label>
</div>
))}
</RadioGroup>
</fieldset>
<fieldset className="grid gap-4">
<legend className="mb-4 bl-type-label">Practice difficulty</legend>
<RadioGroup defaultValue="easy" aria-label="Practice difficulty" className="grid grid-cols-3 gap-3">
<RadioCard value="easy" aria-label="Easy"><strong>Easy</strong><span>Start with guidance</span></RadioCard>
<RadioCard value="intermediate" aria-label="Intermediate"><strong>Intermediate</strong><span>Practice at your pace</span></RadioCard>
<RadioCard value="hard" aria-label="Hard"><strong>Hard</strong><span>Try a challenge</span></RadioCard>
</RadioGroup>
</fieldset></div>
);
}
States & interaction
Appearance, behavior and keyboard checks.
- Document initial, selected, disabled and focus states. Selection changes an indicator or position as well as color.
- Use Space for selection controls; arrow keys change radios and sliders. Checkbox supports a mixed state.
- Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.
API Reference
BrutalLab-specific properties. Native attributes are supported as well.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | uncontrolled | Selected item. |
| onValueChange | function | — | Reports a selection change. |
Accessibility
Rules that should remain intact when adapting the component to a product.
Keep visible text labels and the semantic HTML shown in the example.
Retain keyboard focus styles and test the composition with keyboard navigation.
Use className for visual customization; preserve the primitive ARIA attributes.