Radio

Radio

A radio input component for selecting a single option from a set, with support for both standalone and group usage.


Import

tsx
import { Radio, RadioGroup } from "asheeui";

Usage

tsx
"use client";
import { useState } from "react";
import { Radio, RadioGroup } from "asheeui";
export default function Basic() {
const [value, setValue] = useState<string>("");
return (
<RadioGroup
value={value}
onChange={setValue}
label="Select your preference"
>
<Radio value="option1" label="Option 1" />
<Radio value="option2" label="Option 2" />
<Radio value="option3" label="Option 3" />
</RadioGroup>
);
}

Examples

Variant

Orientation

Controlled

Selected: option1

Default value

Standalone radio (without group)

With description on individual radios


Inheritance

Radio and RadioGroup share common foundational props with <Input />, including:

  • size, radius, variant, color
  • label, labelAlign, description, message
  • status, required, disabled
  • className

Reference: For a complete list of inherited props with detailed descriptions, see the Input documentation.

What Radio adds

Radio extends Input with the following additional features:

FeatureDescription
Group ManagementRadioGroup manages shared state across multiple Radio components
Selection StateControlled and uncontrolled selection handling
Card VariantRadio rendered as a card-style container for enhanced visual selection
Individual DescriptionsEach radio can have its own description text
OrientationHorizontal or vertical layout for the group

What Radio modifies

ModificationDescription
valueReplaced with string values for radio selection
onChangeReceives the selected value instead of an event
typeNot applicable - Radio uses native radio inputs
placeholderNot applicable

What Radio does not inherit

The following Input props are not available on Radio/RadioGroup:

PropReason
placeholderNot applicable for radio inputs
startContentNot applicable - no input adornments
endContentNot applicable - no input adornments
isLoadingNot applicable - no loading state
inputModeNot applicable

All other Input props are fully supported. See the Input documentation for the complete list.


RadioGroup Props

PropTypeDefaultDescription
childrenReactNodeNoneRadio components (required)
namestringAuto-generatedName attribute for radio inputs
valuestringNoneControlled selected value
defaultValuestringNoneDefault selected value
onChange(value: string) => voidNoneCallback when selection changes
size"sm" | "md" | "lg""md"*Size scale
color"none" | "default" | "primary" | "secondary" | "danger" | "warning" | "success""primary"*Semantic color
variant"default" | "card""default"*Visual style
orientation"horizontal" | "vertical""vertical"Layout direction
status"default" | "error" | "success" | "warning""default"Validation status
labelstringNoneGroup label
labelAlign"left" | "top""left"*Label position
descriptionstringNoneHelp text below the group
messagestringNoneStatus message
requiredbooleanfalseShows required indicator
disabledbooleanfalseDisables all radios
classNamestringNoneExtra classes

Radio Props

PropTypeDefaultDescription
valuestringNoneRadio value (required)
labelReactNodeNoneRadio label
descriptionReactNodeNoneOptional description text
size"sm" | "md" | "lg"Inherits from groupSize scale
color"none" | "default" | "primary" | "secondary" | "danger" | "warning" | "success"Inherits from groupSemantic color
radius"none" | "xs" | "sm" | "md" | "lg" | "xl" | "full""full"*Corner rounding
variant"default" | "card"Inherits from groupVisual style
status"default" | "error" | "success" | "warning"Inherits from groupValidation status
checkedbooleanNoneControlled checked state
defaultCheckedbooleanfalseDefault checked state
onChange(checked: boolean, value: string, event: ChangeEvent) => voidNoneCallback when radio changes
disabledbooleanInherits from groupDisables the radio
classNamestringNoneExtra classes

* Falls back through Global Configuration if not set. See below.


Global Configuration

Radio and RadioGroup read defaults from four places, in this order of precedence:

  1. Instance prop: set directly on <Radio /> or <RadioGroup />
  2. Component config: components.radio in your ashee.config
  3. Theme default: defaultColor / defaultRadius in your ashee.config
  4. Built-in fallback: component's internal default values

Component config

ts
// ashee.config.ts
import type { ExternalConfig } from "asheeui";
export const config: ExternalConfig = {
components: {
radio: {
size: "md",
color: "primary",
radius: "full",
variant: "default",
labelAlign: "left",
},
},
};

Built-in fallbacks

ts
{
size: "md",
radius: "full",
variant: "default",
color: "primary",
status: "default",
labelAlign: "left",
}

Accessibility

  • Renders native <input type="radio"> elements with proper semantics
  • Group uses role="radiogroup"
  • Labels are associated with inputs via htmlFor/id
  • Supports keyboard navigation with arrow keys
  • Implements focus-visible rings for keyboard navigation
  • Uses aria-invalid for error states
  • Uses aria-disabled for disabled states
  • Card variant maintains proper focus indicators

Notes

  • Group Context: Radio components inherit properties (size, color, variant, disabled, status) from their parent RadioGroup.
  • Card Variant: The card variant wraps each radio option in a bordered container that highlights when selected.
  • Controlled vs Uncontrolled: Use value/onChange on RadioGroup for controlled usage, or defaultValue for uncontrolled.
  • Standalone Usage: Radio can be used without a RadioGroup by providing name and handling state manually.
  • Radius: When using variant="card", the full radius is automatically mapped to xl for proper visual appearance.
  • Individual Descriptions: Each radio can have its own description text, useful for explaining different options.
  • Orientation: RadioGroup supports horizontal and vertical layouts for flexible design.
  • Inheritance: Radio and RadioGroup share common props with Input but omit input-specific adornments.
Previous

← PasswordInput

Next

ResizableScreen →