Radio

A styled native radio button, with an optional group wrapper.

Default

RadioGroup groups related radio buttons and manages the selected value.

tsx

import { RadioGroup, Radio } from "@hummingbirdui/react";

export default function RadioDefault() {
  return (
    <RadioGroup name="plan" defaultValue="pro" className="flex flex-col gap-2">
      <Radio value="free" label="Free" />
      <Radio value="pro" label="Pro" />
      <Radio value="team" label="Team" />
    </RadioGroup>
  );
}

Colors

The color prop offers primary (default), secondary, success, info, warning, danger, and neutral.

tsx

import { Radio } from "@hummingbirdui/react";

export default function RadioColors() {
  return (
    <div className="flex flex-col gap-2">
      <Radio name="c-primary" color="primary" label="Primary" defaultChecked />
      <Radio name="c-secondary" color="secondary" label="Secondary" defaultChecked />
      <Radio name="c-success" color="success" label="Success" defaultChecked />
      <Radio name="c-info" color="info" label="Info" defaultChecked />
      <Radio name="c-warning" color="warning" label="Warning" defaultChecked />
      <Radio name="c-danger" color="danger" label="Danger" defaultChecked />
      <Radio name="c-neutral" color="neutral" label="Neutral" defaultChecked />
    </div>
  );
}

Sizes

The size prop offers three sizes: sm (default), md, and lg.

tsx

import { RadioGroup, Radio } from "@hummingbirdui/react";

export default function RadioSizes() {
  return (
    <RadioGroup name="size" defaultValue="md" className="flex flex-col gap-2">
      <Radio value="sm" size="sm" label="Small" />
      <Radio value="md" size="md" label="Medium" />
      <Radio value="lg" size="lg" label="Large" />
    </RadioGroup>
  );
}

Inline

The inline prop lays fields out in a row.

tsx

import { RadioGroup, Radio } from "@hummingbirdui/react";

export default function RadioInline() {
  return (
    <RadioGroup name="billing" defaultValue="monthly">
      <Radio inline value="monthly" label="Monthly" />
      <Radio inline value="yearly" label="Yearly" />
    </RadioGroup>
  );
}

Disabled

tsx

import { RadioGroup, Radio } from "@hummingbirdui/react";

export default function RadioDisabled() {
  return (
    <RadioGroup name="plan-disabled" defaultValue="free" className="flex flex-col gap-2">
      <Radio value="free" label="Free" />
      <Radio value="pro" label="Pro (unavailable)" disabled />
    </RadioGroup>
  );
}

API Reference

Radio

PropTypeDefaultDescription
color"primary" | "secondary" | "success" | "info" | "warning" | "danger" | "neutral""primary"Color theme of the radio.
size"sm" | "md" | "lg""sm"Size of the radio.
labelReact.ReactNodeText rendered beside the control, wrapped in a clickable label.
inlinebooleanfalseLay the field out inline.
classNamestringAdditional classes merged with the generated classes.

RadioGroup

PropTypeDefaultDescription
namestringShared name applied to every radio in the group.
valuestringControlled selected value.
defaultValuestringUncontrolled initial value.
onValueChange(value: string) => voidFires with the newly selected value.
classNamestringAdditional classes merged with the generated classes.

Styling

Hummingbird React radio is styled entirely through Hummingbird's utility classes and CSS variables.

  • See the full list of available radio classes in the Class overview.
  • Visit the CSS Variables documentation to explore all available variables.