Radio

Choose one of several mutually exclusive options.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-radio-group
  defaultvalue="monthly"
  position="horizontal"
  size="medium"
  variant="outlined"
  name="billing"
  id="sample"
>
  <sy-radio value="monthly">Monthly</sy-radio>
  <sy-radio value="yearly">Yearly</sy-radio>
</sy-radio-group>

Usage guide

#

Let users choose exactly one mutually exclusive option. Place items inside sy-radio-group and give each a unique value.

  1. Write the error message in the error slot.

    Inside the component, add <span slot="error">Error message</span>. You can include links and other guidance as well as text. For inputs supporting noNativeValidity, enable it to show this guidance instead of a browser popup. Switch always displays errors below the component.

  2. Report business rule failures with setCustomError().

    For example, if the server rejects a duplicate value, update the error slot and call setCustomError(). This method does not take a message argument. A custom error also blocks form submission.

  3. Clear the error after resolving it and check whether submission is allowed.

    Use clearCustomError() to clear a business rule error. Required-field and format validation remain active. await checkValidity() returns true or false; reportValidity() validates and displays errors. Read valid named values through FormData on submission.

Standard option list

Use regular Radio for forms where users read descriptions before choosing.

Button selection

Show short options such as periods or view modes with sy-radio-button. Adjust group direction, size, and style together.

Feature examples

#

Choose a feature from 26 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Usage examples · Group Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Checked

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Size

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Variant

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Checked

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / Default Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / No Native Validity

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / Position

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / Readonly

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Group Attributes / Required

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Readonly

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Methods · Group Methods / Check Validity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Group Methods / Get Status

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Group Methods / Report Validity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Group Methods / Set Custom Error

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Events · Selected

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Group Events / Changed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Selected

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Usage examples · Solid button selection

Use filled radio buttons to show the selected yearly billing option.

View code
HTML
<sy-radio-group
  defaultvalue="yearly"
  position="horizontal"
  size="medium"
  variant="solid"
  name="billing"
  id="sample"
>
  <sy-radio-button value="monthly">Monthly</sy-radio-button>
  <sy-radio-button value="yearly">Yearly</sy-radio-button>
</sy-radio-group>

<script type="module">
  const component1 = document.querySelector("#sample");
  Object.assign(component1, {
    "variant": "solid",
    "defaultValue": "yearly"
  });
</script>

API reference

#

Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.

<sy-radio-group>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseBlock user interaction and keyboard focus.
string''Initially selected value.
booleanfalseDisplay the current value while preventing edits.
booleanfalseFail form validation when no value is provided.
'small' | 'medium' | 'large''medium'Component size.
'horizontal' | 'vertical''horizontal'Item layout direction.
'outlined' | 'solid''outlined'Component display style.
string''Field name used in FormData.
booleanfalseUse the app's error UI instead of the browser's built-in error display. checkValidity still performs validation.

Events

EventDetailDescription
CustomEvent<{ value: string; isValid: boolean; status: string }>Emitted when the value or selection state changes.

Methods

MethodReturnsDescription
Promise<boolean>Return true if the current constraints are satisfied, otherwise false.
Promise<boolean>Validate the current value and display errors to the user.
Promise<void>Set a custom error state.
Promise<void>Clear the custom error state.
Promise<"" | "custom" | "valueMissing">Return the current validation state.

Slots

SlotDescription
Component body or child items.
Validation error message.

<sy-radio>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseSelected or on state.
booleanfalseBlock user interaction and keyboard focus.
booleanfalseDisplay the current value while preventing edits.
string''Current value or item identifier.

Events

EventDetailDescription
CustomEvent<string>Emitted when the user selects an item.

Slots

SlotDescription
Component body or child items.

<sy-radio-button>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseSelected or on state.
booleanfalseBlock user interaction and keyboard focus.
stringundefinedCurrent value or item identifier.
'small' | 'medium' | 'large''medium'Component size.
'outlined' | 'solid''outlined'Component display style.

Events

EventDetailDescription
CustomEvent<string>Emitted when the user selects an item.

Slots

SlotDescription
Component body or child items.