Radio Group

A set of mutually exclusive options. Fully accessible, keyboard-navigable, and styled to match the bloom palette.

Installation

npm install @bloomkit/react

Usage

import { RadioGroup, RadioGroupItem } from "@bloomkit/react";
 
<RadioGroup defaultValue="calm">
  <RadioGroupItem value="calm" label="Calm" />
  <RadioGroupItem value="focused" label="Focused" />
  <RadioGroupItem value="energized" label="Energized" />
</RadioGroup>

Controlled

const [value, setValue] = useState("calm");
 
<RadioGroup value={value} onValueChange={setValue}>
  <RadioGroupItem value="calm" label="Calm" />
  <RadioGroupItem value="focused" label="Focused" />
  <RadioGroupItem value="energized" label="Energized" />
</RadioGroup>

Without labels

<RadioGroup defaultValue="a">
  <RadioGroupItem value="a" aria-label="Option A" />
  <RadioGroupItem value="b" aria-label="Option B" />
</RadioGroup>

Props

RadioGroup

PropTypeDefaultDescription
valuestringControlled selected value
defaultValuestringInitial selected value (uncontrolled)
onValueChange(value: string) => voidCalled when the selected value changes
disabledbooleanfalseDisables all items in the group
classNamestring""Additional Tailwind classes

RadioGroupItem

PropTypeDefaultDescription
valuestringThe value this item represents
labelstringText label rendered beside the radio button
disabledbooleanfalseDisables this item independently
classNamestring""Additional Tailwind classes