Radio Group

A set of checkable buttons where only one can be selected at a time.

Overview

The RadioGroup component allows users to select a single option from a set of mutually exclusive choices. Built on Base UI primitives, it provides a fully accessible radio button group with customizable sizes and flexible styling options.

Usage

import { RadioGroup, RadioGroupItem, Label } from "@tilt-legal/cubitt-components/primitives";
<RadioGroup defaultValue="option-1">
  <div className="flex items-center gap-2">
    <RadioGroupItem value="option-1" id="option-1" />
    <Label htmlFor="option-1">Option 1</Label>
  </div>
  <div className="flex items-center gap-2">
    <RadioGroupItem value="option-2" id="option-2" />
    <Label htmlFor="option-2">Option 2</Label>
  </div>
</RadioGroup>


Examples

Sizes

Radio groups in different sizes.

Disabled

Radio buttons can be individually disabled.

With Description

Radio buttons with additional descriptive text.

Card Style

Radio buttons styled as interactive cards.

URL State

Sync radio group selection with the URL. Try selecting an option and refreshing the page.


API Reference

RadioGroup

The root container component that manages the radio button group.

PropTypeDefaultDescription
valuestring-The controlled value of the selected radio button.
defaultValuestring-The default value when uncontrolled.
onValueChange(value: string) => void-Callback fired when the selected value changes.
disabledbooleanfalseWhether all radio buttons in the group are disabled.
namestring-The name attribute for the radio group (used in forms).
requiredbooleanfalseWhether the radio group is required in a form.
size"sm" | "md" | "lg""md"Size variant applied to all child RadioGroupItem components.
classNamestring-Additional CSS classes for the radio group container.
data-slotstring-Data attribute for styling and testing hooks.

URL State Props

When provided with a paramName, the radio group will sync its selection with URL parameters via TanStack Router search params.

PropTypeDefaultDescription
paramNamestringURL parameter name for syncing state with URL. Enables URL state management.
paramValuestringControlled value for the URL parameter.
onUrlValueChange(value: string) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when value equals default.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

RadioGroupItem

Individual radio button within a RadioGroup.

PropTypeDefaultDescription
valuestring-The unique value for this radio button (required).
idstring-The id attribute for the radio button (used with Label htmlFor).
disabledbooleanfalseWhether this specific radio button is disabled.
size"sm" | "md" | "lg"-Size variant (inherits from RadioGroup if not specified).
classNamestring-Additional CSS classes for the radio button.
data-slotstringData attribute for styling and testing hooks.

Notes

  • Radio buttons must be used within a RadioGroup component
  • Each RadioGroupItem should have a unique value prop within its group
  • Use the id prop on RadioGroupItem and htmlFor on Label for proper label association
  • The size prop on RadioGroup automatically applies to all child items via Context
  • Individual RadioGroupItem components can override the group's size if needed

On this page