VelocityUI logoVelocityUI

RadioGroup

An accessible radio group rendered as a fieldset with a legend. Accepts an options array supporting labels, descriptions, and disabled states. Supports both vertical and horizontal layouts.

Import

tsx
import { RadioGroup } from 'https://git.cameronlow.com/cam/VelocityUI/packages'

Preview

Select a plan
Up to 3 projects
Unlimited projects
Custom pricing
T-shirt size

Props

PropTypeDefaultDescription
namestringShared name attribute for the radio inputs.
labelstringGroup label rendered as a <legend>.
optionsRadioOption[]Array of { value, label, description?, disabled? }.
valuestringControlled selected value.
defaultValuestringUncontrolled default selected value.
onChange(value: string) => voidCallback fired when selection changes.
orientation'vertical' | 'horizontal''vertical'Layout direction of the radio options.
size'sm' | 'md' | 'lg''md'Controls radio and label size.
errorstringError message for the entire group.

Examples

Basic

tsx
import { RadioGroup } from 'https://git.cameronlow.com/cam/VelocityUI/packages'

export default function Example() {
  return (
    <RadioGroup
      name="plan"
      label="Select a plan"
      defaultValue="pro"
      options={[
        { value: 'free', label: 'Free', description: 'Up to 3 projects' },
        { value: 'pro', label: 'Pro', description: 'Unlimited projects' },
        { value: 'enterprise', label: 'Enterprise', description: 'Custom pricing' },
      ]}
    />
  )
}

Horizontal

tsx
import { RadioGroup } from 'https://git.cameronlow.com/cam/VelocityUI/packages'

export default function Example() {
  return (
    <RadioGroup
      name="size"
      label="T-shirt size"
      orientation="horizontal"
      options={[
        { value: 's', label: 'S' },
        { value: 'm', label: 'M' },
        { value: 'l', label: 'L' },
        { value: 'xl', label: 'XL' },
      ]}
    />
  )
}

Theming

Apply a named theme class to <body> or any parent element. All VelocityUI components inside that element will automatically adopt its colors, shadows, and effects. Combine with a density modifier for complete control:

css
/* Pick any named theme */
<body class="vui-theme-ocean">

/* Add a density modifier (optional) */
<body class="vui-theme-midnight vui-density-compact">
<body class="vui-theme-construction vui-density-spacious">

/* Available themes */
/* default  midnight  ocean */
/* construction  glass  soft  high-contrast  monochrome-red */

/* Available densities */
/* vui-density-compact  vui-density-comfortable  vui-density-spacious */