RadioGroup
Single choice from a short list, as a fieldset of radios; supports required, hint and error.
Code
import * as React from 'react';
import { RadioGroup } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
display: 'flex',
gap: 40,
flexWrap: 'wrap',
}}
>
<RadioGroup label="Text size" options={['Small', 'Medium', 'Large']} defaultValue="Medium" />
<RadioGroup label="Plan" required options={['Free', 'Pro']} error="Choose a plan." />
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { RadioGroup } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/radio-group.jsonGuidelines
- 2–5 options. More than 5: use Select. Stack vertically unless options are very short (
inline). - With useForm:
{...f.field('plan', 'value')}.
Props
| Prop | Type | Required |
|---|---|---|
options | Array<string | { value: string; label: React.ReactNode; disabled?: boolean }> | Yes |
value | string | No |
defaultValue | string | No |
onChange | (value: string) => void | No |
label | string | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
optional | boolean | No |
name | string | No |
inline | boolean | No |
className | string | No |