Skip to main content

Starwind UI v1.7.0 is now available!

Radio Group

Choose an option

Installation

Usage

Variants

Default
Primary
Secondary
Info
Success
Warning
Error

Sizes

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 Props

PropTypeDefaultDescription
namestringRequiredName for the radio group inputs
valuestring-Current value of the radio group
defaultValuestring-Default value if value not provided
legendstring-Screen reader label for the group
requiredbooleanfalseWhether the radio group is required
disabledbooleanfalseWhether the radio group is disabled
orientation"vertical" | "horizontal""vertical"Layout orientation of radio items

This component also accepts all standard HTML attributes for <fieldset> elements.

RadioGroupItem Props

PropTypeDefaultDescription
valuestringRequiredValue of the radio item
idstring-ID for the radio input
namestring-Name for the radio input (use group’s name)
checkedbooleanfalseWhether the radio is checked
disabledbooleanfalseWhether the radio is disabled
size"sm" | "md" | "lg""md"Size of the radio button
variant"default" | "primary" | "secondary" | "info" | "success" | "warning" | "error""default"Color variant of the radio button

This component also accepts all standard HTML attributes for <input type="radio"> elements.

Changelog

v1.0.0

  • Initial release with starwind v1.7.0