Skip to content

Radio - Elements ​

Radios allow users to select a single option from a list of choices.

AndroidreleasedElementsreleasediOSreleasedReactreleasedVuereleased

Accessibility ​

Usage ​

A radio input typically consists of two components:

  • <w-radio-group> - A grouping wrapper that manages labeling, help text, roving keyboard focus, and validation for child radios.
  • <w-radio> - A single radio with required and invalid states.

In advanced cases you may use <w-radio> without <w-radio-group>. If you're unsure what's correct in your case, always wrap <w-radio> in a <w-radio-group>.

The components automatically handle:

  • Form integration and constraint validation
  • Required state handling with validation messages
  • Accessibility attributes, keyboard interaction, and labeling
html
<w-radio-group label="Select an option" name="usage">
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Validation ​

Set the invalid attribute to display a radio group as invalid, for example if nothing was selected and the group was required.

invalid can be paired with help-text to provide feedback to the user about how to correct the error. However, since the invalid + required use case is so common you can omit help-text to use a generic built-in one.

html
<w-radio-group label="Select an option" name="usage" required invalid>
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Examples ​

html
<w-radio-group label="Select an option" name="examples">
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Optional ​

Add the optional prop to <w-radio-group> to indicate that the user doesn't have to pick an option.

html
<w-radio-group label="Select an option" name="optional" optional>
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Help text ​

Use help-text to give additional context when the label and options are not enough.

html
<w-radio-group label="Select an option" name="help" help-text="Pick whichever you like">
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Disabled ​

Keep in mind that using disabled is an anti-pattern.

There will always be users who don't understand why an element is disabled, or users who can't even see that it is disabled because of poor lighting conditions or other reasons.

Please consider more informative alternatives before choosing to use disabled on an element.

html
<w-radio-group label="Select an option" name="disabled" disabled>
    <w-radio value="one">Option 1</w-radio>
    <w-radio value="two">Option 2</w-radio>
    <w-radio value="three">Option 3</w-radio>
</w-radio-group>

Styling API ​

This section documents the supported styling hooks for <w-radio> and <w-radio-group>.

Use these hooks to customize appearance without relying on internal structure or selectors.

Before changing the default styles, remember that doing so can result in less consistent experiences for users across the product. Prefer defaults.

  • Prefer component tokens for size, spacing, and state styling.
  • Use parts only for small, local tweaks.
  • Avoid relying on internal class names or selectors.

Parts ​

The radio exposes a small set of parts that can be targeted for last‑mile layout or typography tweaks.

PartTargetsTypical use
controlradio control (circle)minor alignment or sizing tweaks
labellabel contenttypography tweaks

Example:

css
w-radio::part(label) {
  font-weight: 600;
}

w-radio::part(control) {
  margin-top: 1px;
}

Parts are intended as an escape hatch. Prefer component tokens for anything state‑ or size‑related.

Component tokens ​

Component tokens (--w-c-radio-*) act as inputs to the radio styling. They can be set directly on the component or inherited from a parent container.

css
.settings-panel {
  --w-c-radio-gap: 12px;
}

Defaults are defined internally; setting a token is always optional.

Layout & size ​

TokenPurposeDefault
--w-c-radio-gapspace between control and label8px
--w-c-radio-sizewidth/height of the control2rem
--w-c-radio-radiusborder radius of the control50%
--w-c-radio-border-widthborder width1px
--w-c-radio-checked-border-widthborder width when checked0.6rem

Colors ​

TokenPurposeDefault
--w-c-radio-bgcontrol backgroundtheme default
--w-c-radio-border-colorcontrol border colortheme default
--w-c-radio-border-color-checkedborder color when checkedtheme default
--w-c-radio-label-colorlabel text colorcurrentColor

Invalid state ​

TokenPurposeDefault
--w-c-radio-border-color-invalidborder color when invalidtheme default

Disabled state ​

TokenPurposeDefault
--w-c-radio-bg-disabledbackground when disabledtheme default
--w-c-radio-border-color-disabledborder when disabledtheme default
--w-c-radio-label-color-disabledlabel color when disabledtheme default
--w-c-radio-cursor-disabledcursor when disablednot-allowed

Typography ​

TokenPurposeDefault
--w-c-radio-label-font-sizelabel font sizetheme default
--w-c-radio-label-line-heightlabel line heighttheme default

Focus ​

TokenPurposeDefault
--w-c-radio-outline-widthfocus outline width2px
--w-c-radio-outline-colorfocus outline colortheme default
--w-c-radio-outline-offsetfocus outline offsettheme default

Interaction ​

TokenPurposeDefault
--w-c-radio-cursorcursor in enabled statepointer

Motion ​

TokenPurposeDefault
--w-c-radio-transitiontransition for control150ms cubic-bezier(0.4, 0, 0.2, 1)

Transitions are automatically disabled when prefers-reduced-motion: reduce is active.

<w-radio-group> API ​

Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).

Properties ​

NameTypeDefaultSummary
disabledbooleanfalseDisables the radio group and all child radios.
help-textstring''Help text for the radio group.
invalidbooleanfalseMarks the radio group as invalid.
labelstring''Label for the radio group.
namestring | nullnullThe name of the select when submitting the form.
optionalbooleanfalseWhether to show optional text next to the label.
requiredbooleanfalseMakes selecting a radio in the the group required.

Property Details ​

disabled ​

Disables the radio group and all child radios.

  • Type: boolean
  • Default: false

help-text ​

Help text for the radio group.

If you set required and invalid the group gets a default error message, but you can override it with this attribute.

  • Type: string
  • Default: ''

invalid ​

Marks the radio group as invalid.

  • Type: boolean
  • Default: false

label ​

Label for the radio group.

  • Type: string
  • Default: ''

name ​

The name of the select when submitting the form.

  • Type: string | null
  • Default: null

optional ​

Whether to show optional text next to the label.

  • Type: boolean
  • Default: false

required ​

Makes selecting a radio in the the group required.

  • Type: boolean
  • Default: false

<w-radio> API ​

Properties ​

NameTypeDefaultSummary
checkedbooleanfalseDraws the radio in a checked state (reflected to attribute).
disabledbooleanfalseDisables the radio.
invalidbooleanfalseDraws the radio in an invalid state.
namestring-The name of the radio, submitted as a name/value pair with form data.
requiredbooleanfalseMakes the radio a required field.
valuestring | nullnullThe radio's value. When selected, the radio group will receive this value.

Property Details ​

checked ​

Draws the radio in a checked state (reflected to attribute).

  • Type: boolean
  • Default: false
disabled ​

Disables the radio.

  • Type: boolean
  • Default: false
invalid ​

Draws the radio in an invalid state.

  • Type: boolean
  • Default: false
name ​

The name of the radio, submitted as a name/value pair with form data.

  • Type: string
  • Default: -
required ​

Makes the radio a required field.

  • Type: boolean
  • Default: false
value ​

The radio's value. When selected, the radio group will receive this value.

  • Type: string | null
  • Default: null

Questions? ​

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system