Skip to main content

Starwind UI v1.12 is now available!

Radio Group

Choose an option

Installation

Usage

variant

Default
Primary
Secondary
Info
Success
Warning
Error

size

Small
Medium
Large

orientation

Vertical (Default)

Horizontal

Event Handling

The RadioGroup component emits a starwind:value-change event when a radio option is selected. This can be listened to in order to update your UI based on the event.detail.value property.

Radio Group Event Test

Choose an option
Selected value: none

The event emission happens when a radio item is selected and looks like:

const event = new CustomEvent<RadioGroupChangeEvent["detail"]>("starwind:value-change", {
detail: {
value: target.value, // string value of the selected radio
radioGroupId: this.radioGroupId, // ID of the radio group
},
bubbles: true,
});
this.radioGroup.dispatchEvent(event);

API Reference

RadioGroup

The root component that manages the radio group state and keyboard navigation.

PropTypeDefault
namestringRequired
valuestring-
defaultValuestring-
legendstring-
requiredbooleanfalse
disabledbooleanfalse
orientation"vertical" | "horizontal""vertical"
classstring-
<RadioGroup name="options" defaultValue="option-1" legend="Choose an option">
<!-- Radio items -->
</RadioGroup>

Additional Notes:

  • name: Name for the radio group inputs
  • legend: Screen reader label for the group
  • orientation: Layout orientation of radio items

RadioGroupItem

Individual radio button item within the group.

PropTypeDefault
valuestringRequired
idstring-
namestring-
checkedbooleanfalse
disabledbooleanfalse
size"sm" | "md" | "lg""md"
variant"default" | "primary" | "secondary" | "info" | "success" | "warning" | "error""default"
classstring-
<RadioGroupItem id="option-1" value="option-1" name="options" />

Changelog

v1.2.2

  • Removed debug logging statements

v1.2.1

  • Add named slot “icon” to RadioGroupItem to enable easy icon swapping

v1.2.0

  • style and focus state updates

v1.1.0

  • Add data-slot attribute to enable global styling updates

v1.0.0

  • Initial release with starwind v1.7.0