DocsComponentsTemplatesThemesGitHub

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.json

Guidelines

  • 2–5 options. More than 5: use Select. Stack vertically unless options are very short (inline).
  • With useForm: {...f.field('plan', 'value')}.

Props

PropTypeRequired
optionsArray<string | { value: string; label: React.ReactNode; disabled?: boolean }>Yes
valuestringNo
defaultValuestringNo
onChange(value: string) => voidNo
labelstringNo
hintReact.ReactNodeNo
errorReact.ReactNodeNo
requiredbooleanNo
optionalbooleanNo
namestringNo
inlinebooleanNo
classNamestringNo

Edit this example on GitHub