Skip to main content

Radio Button Component

Figma

The glu-radio component is an accessible radio button that supports both left and right labels, error messaging, and helper text. It is designed to integrate with radio groups for single selection behavior and provides proper ARIA attributes and keyboard interactions. The component emits a glChange event when its state changes.

Basic Radio Button

A simple radio button with a left label and default unchecked state.

Result
Loading...
Live Editor
<glu-radio leftLabel="Option 1" name="example"></glu-radio>

Radio with Right Label

Display a radio button with a right-aligned label.

Result
Loading...
Live Editor
<glu-radio rightLabel="Option A" name="example"></glu-radio>

Radio with Both Left and Right Labels

Combine both left and right labels to provide additional context.

Result
Loading...
Live Editor
<glu-radio leftLabel="Select" rightLabel="Option B" name="example"></glu-radio>

Radio with Error and Helper Text

Display error messaging and supplemental helper text when validation fails.

Result
Loading...
Live Editor
<glu-radio
  leftLabel="Option 2"
  error="Selection required"
  helperText="Please select an option"
  helperIcon="error-icon"
  name="example"
></glu-radio>

Disabled Radio Button

Prevent user interaction by disabling the radio button.

Result
Loading...
Live Editor
<glu-radio leftLabel="Option 3" disabled name="example"></glu-radio>

Example: Multiple Options Radio Buttons

Below is an example of a radio button group for selecting a favorite color. All radio buttons share the same name attribute so they behave as a group. Only one option can be selected at a time.

Result
Loading...
Live Editor
<div style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
  <glu-radio leftLabel="Red" name="favoriteColor"></glu-radio>
  <glu-radio leftLabel="Green" name="favoriteColor" checked></glu-radio>
  <glu-radio leftLabel="Blue" name="favoriteColor"></glu-radio>
</div>

Properties

PropertyAttributeDescriptionTypeDefault
checkedcheckedWhether the radio is currently selectedbooleanfalse
disableddisabledDisables the radio buttonbooleanfalse
errorerrorThe error message to display.stringundefined
helperIconhelper-iconHelper icon namestringundefined
helperIconVarianthelper-icon-variantHelper icon variant"outline" | "solid"'outline'
helperTexthelper-textSupplemental helper textstringundefined
leftLabelleft-labelOptional left label text displayed adjacent to the radio.stringundefined
namenameName attribute for radio group associationstringundefined
rightLabelright-labelOptional right label text displayed adjacent to the radio.stringundefined

Events

EventDescriptionType
glChangeEmitted when the radio is selectedCustomEvent<{ value: boolean; event: Event; }>

Dependencies

Depends on

Graph


Built with StencilJS