RadioGroup
A set of checkable circles where only one can be selected at a time, on a filled container surface in S/M/L sizes. The dot animates in and out with a spring on selection change. All colors come from tokens in @npolyhunter/ds/theme.css.
Playground
Live preview
Examples
Sizes
<RadioGroup defaultValue="small">
<RadioGroupItem value="small" size="small" />
<RadioGroupItem value="medium" size="medium" />
<RadioGroupItem value="large" size="large" />
</RadioGroup>States
<RadioGroupItem value="a" />
// Checked — border moves to border-strong and the dot scales in
<RadioGroupItem value="b" />
// Error — border uses status-danger-border; on focus it becomes 2px status-danger-foreground
// plus a danger-tinted ring
<RadioGroupItem value="c" invalid />
// Disabled — subtle border, 45% opacity
<RadioGroupItem value="d" disabled />
<RadioGroupItem value="e" disabled />Vertical group
import { Label, RadioGroup, RadioGroupItem } from "@npolyhunter/ui";
<RadioGroup defaultValue="comfortable">
<div className="flex items-center space-x-2">
<RadioGroupItem value="default" id="r1" />
<Label htmlFor="r1">Default</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="comfortable" id="r2" />
<Label htmlFor="r2">Comfortable</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="compact" id="r3" />
<Label htmlFor="r3">Compact</Label>
</div>
</RadioGroup>Horizontal group
<RadioGroup defaultValue="comfortable" className="flex flex-wrap items-center gap-4">
<div className="flex items-center space-x-2">
<RadioGroupItem value="default" id="h1" />
<Label htmlFor="h1">Default</Label>
</div>
{/* … */}
</RadioGroup>Code
import { Label, RadioGroup, RadioGroupItem } from "@npolyhunter/ui";
<RadioGroup defaultValue="comfortable">
<div className="flex items-center space-x-2">
<RadioGroupItem value="default" id="r1" />
<Label htmlFor="r1">Default</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="comfortable" id="r2" />
<Label htmlFor="r2">Comfortable</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="compact" id="r3" />
<Label htmlFor="r3">Compact</Label>
</div>
</RadioGroup>Code
const [value, setValue] = useState("medium");
<RadioGroup value={value} onValueChange={setValue}>
<div className="flex items-center space-x-2">
<RadioGroupItem
value="option"
size="${size}" // "small" | "medium" | "large"
invalid={invalid}
disabled={disabled}
/>
<Label htmlFor="option">{label}</Label>
</div>
</RadioGroup>Used in
No usage found outside previews and tests.
No usage found
