Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Radio

Radio

A Radio lets a user pick exactly one option from a small, fixed set — title, gender, payment method, preferred language. "aegov-radio" handles the individual control — label, hint, states, sizes, and colour variants — while "aegov-radio-group" wraps a set of radios in a native "fieldset", sharing the "name" attribute, propagating sizing, and emitting a single event with the currently selected value.

Interactive Forms
Status
Active
Introduced
4.0.x
View source code

Anatomy

aegov-radio renders a native <input type="radio">, optionally wrapped in a <label> when label is set, with the hint and error message as sibling regions. aegov-radio-group renders a native <fieldset>/<legend> (with role="radiogroup") around a set of radios, plus its own shared hint and error regions.

Image showing anatomy of a radio

Item Name Description
1 Control The native radio input — circular, checked/unchecked
2 Label Clickable text describing the option (label prop)
3 Hint Supporting helper text shown below the label — stays visible while an error shows
4 Error message Shown after the hint once is-invalid is set
5 Legend (group only) The group's own accessible name, from aegov-radio-group's label

Basics

aegov-radio-group requires a name, shared by every child radio, so form submission and mutual exclusivity work correctly. Give each aegov-radio a value, and set is-checked on the one that should be selected by default.

<aegov-radio-group name="title-basics" label="Title">
  <aegov-radio field-id="title-mr" value="mr" label="Mr" is-checked="true"></aegov-radio>
  <aegov-radio field-id="title-ms" value="ms" label="Ms"></aegov-radio>
  <aegov-radio field-id="title-mrs" value="mrs" label="Mrs"></aegov-radio>
  <aegov-radio field-id="title-dr" value="dr" label="Dr"></aegov-radio>
</aegov-radio-group>

Label and hint

Add hint for supporting helper text underneath a radio's label — it stays visible while a validation error shows, because that is when the user needs it most.

<aegov-radio-group name="contact-method" label="Preferred contact method">
  <aegov-radio field-id="contact-email" value="email" label="Email" hint="We'll send updates to your registered email address." is-checked="true"></aegov-radio>
  <aegov-radio field-id="contact-sms" value="sms" label="SMS" hint="Short text alerts to your registered mobile number."></aegov-radio>
  <aegov-radio field-id="contact-call" value="call" label="Phone call" hint="A representative will call you during working hours."></aegov-radio>
</aegov-radio-group>

States

A radio can be checked, unchecked, disabled (in either checked state), or required. is-disabled on an individual radio disables only that option — use the group's own is-disabled (see Group disabled) to lock every option at once.

<aegov-radio-group name="payment-states" label="Payment method">
  <aegov-radio field-id="pay-card" value="card" label="Credit or debit card" is-checked="true"></aegov-radio>
  <aegov-radio field-id="pay-bank" value="bank" label="Direct bank transfer"></aegov-radio>
  <aegov-radio field-id="pay-cash" value="cash" label="Cash at service centre" is-disabled="true" hint="Currently unavailable due to system maintenance."></aegov-radio>
  <aegov-radio field-id="pay-crypto" value="crypto" label="Cryptocurrency" is-required="true"></aegov-radio>
</aegov-radio-group>

Sizes

size accepts five tokens, from xs up to xl. It scales the control, the label text, and the hint text together, and accepts a responsive breakpoint string when set on the group (e.g. size="sm md:base").

<aegov-radio field-id="radio-size-xs" name="radio-size-xs" size="xs" label="Extra small" is-checked="true"></aegov-radio>
<aegov-radio field-id="radio-size-sm" name="radio-size-sm" size="sm" label="Small" is-checked="true"></aegov-radio>
<aegov-radio field-id="radio-size-base" name="radio-size-base" size="base" label="Base (default)" is-checked="true"></aegov-radio>
<aegov-radio field-id="radio-size-lg" name="radio-size-lg" size="lg" label="Large" is-checked="true"></aegov-radio>
<aegov-radio field-id="radio-size-xl" name="radio-size-xl" size="xl" label="Extra large" is-checked="true"></aegov-radio>

Variant

variant selects the colour family for the rest border, checked fill, and hover halo. On aegov-radio-group, setting variant cascades it to every child that hasn't set its own variant.

Variant Rest border / accent Checked fill
primary primary-600 primary-600
secondary secondary-600 secondary-600
neutral-max aeblack-800 aeblack-800
neutral-min aeblack-400 aeblack-400

Variant example

<aegov-radio field-id="radio-variant-primary" name="radio-variant-primary" variant="primary" is-checked="true" label="Primary"></aegov-radio>
<aegov-radio field-id="radio-variant-secondary" name="radio-variant-secondary" variant="secondary" is-checked="true" label="Secondary"></aegov-radio>
<aegov-radio field-id="radio-variant-neutral-max" name="radio-variant-neutral-max" variant="neutral-max" is-checked="true" label="Neutral-max"></aegov-radio>
<aegov-radio field-id="radio-variant-neutral-min" name="radio-variant-neutral-min" variant="neutral-min" is-checked="true" label="Neutral-min"></aegov-radio>

Orientation

orientation stacks the group's items vertically (default) or lets them wrap horizontally — useful for a compact set of short options such as Yes/No.

<aegov-radio-group name="agree-vertical" label="Do you agree?" orientation="vertical">
  <aegov-radio field-id="agree-v-yes" value="yes" label="Yes"></aegov-radio>
  <aegov-radio field-id="agree-v-no" value="no" label="No"></aegov-radio>
  <aegov-radio field-id="agree-v-unsure" value="unsure" label="Not sure"></aegov-radio>
</aegov-radio-group>
<aegov-radio-group name="agree-horizontal" label="Do you agree?" orientation="horizontal">
  <aegov-radio field-id="agree-h-yes" value="yes" label="Yes"></aegov-radio>
  <aegov-radio field-id="agree-h-no" value="no" label="No"></aegov-radio>
  <aegov-radio field-id="agree-h-unsure" value="unsure" label="Not sure"></aegov-radio>
</aegov-radio-group>

Appearance

appearance, set on aegov-radio-group, cascades a visual layout to every child radio — list adds separator lines, cards turns each item into a bordered card, and pills renders a toggle-chip with the native input visually hidden (but still accessible). A standalone aegov-radio outside any group always renders default.

<aegov-radio-group name="appearance-list" label="List" appearance="list">
  <aegov-radio field-id="app-list-std" value="std" label="Standard"></aegov-radio>
  <aegov-radio field-id="app-list-exp" value="exp" label="Express" is-checked="true"></aegov-radio>
</aegov-radio-group>
<aegov-radio-group name="appearance-cards" label="Cards" appearance="cards">
  <aegov-radio field-id="app-cards-std" value="std" label="Standard"></aegov-radio>
  <aegov-radio field-id="app-cards-exp" value="exp" label="Express" is-checked="true"></aegov-radio>
</aegov-radio-group>
<aegov-radio-group name="appearance-pills" label="Pills" appearance="pills" orientation="horizontal">
  <aegov-radio field-id="app-pills-std" value="std" label="Standard"></aegov-radio>
  <aegov-radio field-id="app-pills-exp" value="exp" label="Express" is-checked="true"></aegov-radio>
</aegov-radio-group>

Group disabled

Setting is-disabled="true" on the group disables every child radio via the native <fieldset disabled> mechanism — no per-child changes needed. Turning it back off restores each child's own is-disabled setting.

<aegov-radio-group name="locked" label="This section is locked while the application is under review" is-disabled="true">
  <aegov-radio field-id="locked-a" value="a" label="Option A"></aegov-radio>
  <aegov-radio field-id="locked-b" value="b" label="Option B" is-checked="true"></aegov-radio>
  <aegov-radio field-id="locked-c" value="c" label="Option C"></aegov-radio>
</aegov-radio-group>

Group validation

is-required, is-invalid, and error-message operate at the group level — validation asks "was at least one option selected?", not "is this specific radio checked?" Set them on aegov-radio-group itself, and give the group its own label so its <fieldset>/<legend> carries a real accessible name; that name is what identifies the group, not any label you may separately give a single field elsewhere in the form.

<aegov-radio-group name="emirate-validation" label="Emirate of residence" is-required="true" is-invalid="true" error-message="Please select your emirate of residence.">
  <aegov-radio field-id="emirate-val-ad" value="ad" label="Abu Dhabi"></aegov-radio>
  <aegov-radio field-id="emirate-val-dxb" value="dxb" label="Dubai"></aegov-radio>
  <aegov-radio field-id="emirate-val-shj" value="shj" label="Sharjah"></aegov-radio>
</aegov-radio-group>

RTL support

The radio uses CSS logical properties throughout. When the document or any ancestor is dir="rtl", the control swaps to the end (right) side of the label, hint text aligns right, list dividers and card borders flip inline-end, and pill spacing follows the writing direction — no extra configuration needed. Left/Right arrow keys follow the reading direction too: in RTL, Arrow Left moves to the next option and Arrow Right to the previous one, as native radios do.

<div dir="rtl">
  <aegov-radio-group name="processing-rtl" appearance="cards" label="سرعة المعالجة">
    <aegov-radio field-id="proc-rtl-standard" value="standard" label="عادية — خلال 5 أيام عمل" hint="مجاناً لمواطني دولة الإمارات." is-checked="true"></aegov-radio>
    <aegov-radio field-id="proc-rtl-express" value="express" label="سريعة — خلال يومي عمل" hint="رسوم إضافية بقيمة 100 درهم."></aegov-radio>
  </aegov-radio-group>
</div>

Usage

Here is the recommended usage of a radio on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Always wrap related radios in aegov-radio-group, and give it a label
This gives the group a shared name (required for correct single-select behaviour) and a <legend> that tells assistive technology the question being asked — not just the individual option text.

Use radios for a small, fixed set of mutually exclusive options — roughly two to seven
For longer lists, a select dropdown scales better. For a single yes/no setting, a toggle is a more familiar interaction model than a two-option radio group.

Pre-select a sensible default with is-checked whenever one exists
A radio group with nothing pre-selected forces every user to make an active choice even when most users want the same, common option — pre-select it and let the minority change it.

Do not use a single standalone radio outside a group
A lone radio has nothing to be mutually exclusive with, which is confusing for anyone using assistive technology — use a checkbox or toggle instead for a single independent option.

API reference

The following are the properties and references of a radio

aegov-radio default properties

AttributeDescriptionTypeDefault

field-id

DOM id reflected on the inner native <input>. Auto-generated if omitted.

string

auto-generated

name

Reflected on the host so ElementInternals can read it for native form submission, and so a parent aegov-radio-group can propagate it via JS property assignment. Not applied to the inner shadow-DOM <input> — see Accessibility.

string

(none)

value

Value identifying this option in form data and in group change events.

string

(none)

is-checked

Whether the radio is selected.

boolean

false

size

Size token. Accepts a responsive breakpoint string the same way Badge/Banner/Checkbox do, e.g. "sm md:base".

xs | sm | base | lg | xl

base

variant

Colour family for the rest border, checked fill, and focus outline.

primary | secondary | neutral-max | neutral-min

primary

appearance

Visual layout set by a parent aegov-radio-group (default/cards/pills/list). Not meant to be set directly on a standalone radio.

default | cards | pills | list

default

is-disabled

Whether the radio is disabled.

boolean

false

is-required

Whether the radio must be checked for the form to submit. Use it only on a standalone radio — inside a group, each inner input sits alone in its own shadow root, so every unchecked required radio would report valueMissing and block the form. Set is-required on aegov-radio-group instead.

boolean

false

label

Label text. When provided, an associated <label> wraps the control so clicking the text also selects it. When omitted, only the bare <input> renders — supply your own visible or aria-label labelling.

string

(none)

hint

Helper text shown below the label (or beside the bare control when label is omitted). It stays visible while an error shows — the error renders after it and both are announced as the description. Use the hint slot instead for rich markup. Hidden entirely in the pills appearance.

string

(none)

is-invalid

Visual + aria-invalid invalid state.

boolean

false

error-message

Inline error message shown when is-invalid is set. Use the error slot for rich markup instead.

string

''

extra-class

Additional CSS classes applied to the internal wrapper.

string

(none)

This component renders inside a real shadow DOM, so extra-class only applies margin/padding (spacing) utilities — e.g. mt-4, md:px-6. Colour, border, typography, and every other visual utility are silently ignored: this is an isolated component whose internal styles can't be overridden, keeping it visually consistent wherever it's used.

aegov-radio-group default properties

AttributeDescriptionTypeDefault

name

Shared name for every radio in the group, set on each child via JS property assignment. Required — Angular's template compiler enforces this at build time.

string

required

appearance

Layout for the whole group. list adds separator lines between items; cards/pills restyle each child radio (cascaded down to every child).

default | list | cards | pills

default

orientation

Stack direction for radio items.

vertical | horizontal

vertical

label

Rendered as the group's <legend> for accessibility.

string

(none)

size

Cascades to every child radio. Accepts a responsive breakpoint string.

xs | sm | base | lg | xl

base

variant

Cascades to every child radio that hasn't set its own variant (a child that explicitly sets variant="primary" keeps it).

primary | secondary | neutral-max | neutral-min

primary

is-disabled

Disables every radio in the group via a native <fieldset disabled>.

boolean

false

is-required

Aggregate-level only — validates that one child radio is checked. Does not mark individual children as required. Sets aria-required="true" on the role="radiogroup" fieldset and adds a visible * to the legend.

boolean

false

is-invalid

Visual + aria-invalid invalid state on the group's <fieldset>.

boolean

false

error-message

Inline error shown below the group when is-invalid is set. Use the error slot for rich markup.

string

''

hint

Helper text shown below the group's items. Stays visible while an error shows — the error renders after it. Use the hint slot for rich markup.

string

''

extra-class

Additional CSS classes applied to the internal fieldset wrapper.

string

(none)

This component renders inside a real shadow DOM, so extra-class only applies margin/padding (spacing) utilities — e.g. mt-4, md:px-6. Colour, border, typography, and every other visual utility are silently ignored: this is an isolated component whose internal styles can't be overridden, keeping it visually consistent wherever it's used.

Events

EventDescriptionComponentDetail

aegovRadioChange

Fired when a single radio's checked state changes.

aegov-radio

{ checked: boolean; value?: string }

aegovRadioGroupChange

Fired whenever the selected radio in the group changes. Carries the newly-selected value, or undefined if none is selected.

aegov-radio-group

{ value: string | undefined }

aegovValidate

Unified validation event, fired on blur, change, and manual validate() calls.

both

AegovValidationDetail<boolean> (radio) / AegovValidationDetail<string | undefined> (group)

Methods

MethodDescriptionComponent

validate(trigger?)

Imperatively re-runs validation and emits aegovValidate. Returns Promise<{ valid, message, validity }>.

both

setCustomValidity(message)

Mirrors HTMLInputElement.setCustomValidity(). An empty string clears the custom error.

both

Slots

SlotDescriptionComponent

(default)

The radio items themselves.

aegov-radio-group

hint

Rich markup for the hint, in place of the plain-text hint prop.

both

error

Rich markup for the error message, in place of the plain-text error-message prop.

both

Pass-through attributes

AttributeNotesForwards to

aria-*

Forwarded automatically, except aria-invalid (owned internally). Your aria-describedby is kept and combined with the hint/error ids. aria-required is also owned internally on the group.

inner <input> (radio) / <fieldset> (group)

data-*

Forwarded automatically on both components.

inner <input> (radio) / <fieldset> (group)

form, tabindex, title

Forwarded on aegov-radio only. Not forwarded by aegov-radio-group.

inner <input>

autofocus

Forwarded on aegov-radio only, including the bare boolean-attribute shorthand (<aegov-radio autofocus>).

inner <input>

id

Not forwarded on either component. Use field-id to control the radio's real inner id.

n/a

class, style

Applied to the host element on both components — stays host-only, never forwarded inward.

host

Notes

The following notes are applicable of this component.

Built-in accessibility

  • aegov-radio renders a real native <input type="radio">, so basic toggling and assistive-technology announcement as a radio button come for free.
  • Setting label wraps the input in a real <label>, so clicking or tapping the text also selects the control — no manual for/id wiring needed.
  • aegov-radio-group renders a native <fieldset>/<legend> pair (with role="radiogroup") when label is set, giving the whole group a single accessible name without extra ARIA wiring.
  • Hint and error text are wired to the input (or fieldset) via aria-describedby automatically whenever hint/error-message (or their slots) are present. The hint stays visible while an error shows, so the description reads the error, then the hint.
  • aegov-radio-group implements the WAI-ARIA radio group keyboard pattern: the group is a single tab stop and the arrow keys move both focus and selection between options.
  • The error region only takes role="alert" after the user has actually interacted with the field once (blurred it, or interacted with the group), so a validation message present at initial page load is not announced as an interruption.

Developer responsibility

The following is required for a developer to add additionally or pay attention to regarding this component.

  • If you omit label, supply aria-label or aria-labelledby yourself — the component does not fall back to any other accessible name.
  • Always wrap related radios in aegov-radio-group and set the group label — this gives assistive technology the question being asked, not just each option's own text.
  • is-required on aegov-radio-group does not block a native form submit, and it shows no error by itself: the group isn't part of the browser's form validation. On submit, call await group.validate('submit'); if the result isn't valid, prevent the submit, set error-message (for example from result.message) and is-invalid on the group, and move focus to the first radio in the group. Clear them when the user makes a choice. See the whole-form validation pattern.
  • Use radios only for genuinely mutually-exclusive choices among a small, fixed set (roughly two to seven options). For a single instantly-applied on/off setting, use aegov-toggle instead; for longer option lists, use aegov-select.
  • Check colour contrast for any custom extra-class background or text colour against your chosen variant.

Additional notes

  • size on both components accepts a responsive breakpoint string, the same convention used by Badge, Banner, and Checkbox (e.g. size="sm md:base").
  • appearance on aegov-radio is written by its parent group and shouldn't be set directly — set appearance on the aegov-radio-group instead. A standalone radio with no parent group always renders default.
  • name/form submission are handled via ElementInternals on the host element, not the inner shadow-DOM <input> — reading radio.name or checking form data works exactly like a native input. The shadow DOM's own <input> also carries the name (so a required radio can report valueMissing), but it never submits anything itself. See the note on keyboard support below for why it matters more here than it does for aegov-checkbox.
  • Because each radio's inner native <input> lives in its own shadow root, the inputs never form a group with each other even when their names match, so the browser has no native "radio button group" to apply its own keyboard behaviour to. aegov-radio-group reimplements mutual exclusivity, the single tab stop and arrow-key navigation in JS instead. See Keyboard support for the resulting behaviour.

Keyboard support

Key Function
Tab Moves focus into the group, landing on the selected radio — or the first enabled radio if none is selected. The group is a single tab stop; the next Tab leaves it.
Shift + Tab Moves focus out of the group. Entering the group backwards with nothing selected lands on the last enabled radio, as native radios do.
Arrow Down / Arrow Right Moves focus to the next enabled radio and selects it, wrapping from the last option to the first. In RTL, Arrow Left moves forward instead of Arrow Right.
Arrow Up / Arrow Left Moves focus to the previous enabled radio and selects it, wrapping from the first option to the last. In RTL, Arrow Right moves back instead of Arrow Left.
Space Selects the focused radio and deselects any other radio checked within the same group.

Arrow keys move focus and change the selection, matching native radios and the WAI-ARIA radiogroup pattern. Disabled radios are skipped. Because moving through the options selects each one, don't trigger consequential side effects on aegovRadioGroupChange.