Forms

Radio

@xui/radio

A single-choice group. The group owns the value, the shared name and a single tab stop — arrow keys move between options per the WAI-ARIA radio pattern. Bind forms to the group, never to individual radios.

Install

pnpm add @xui/radio

Add the barrel to a standalone component's imports:

import { XuiRadioImports } from '@xui/radio';

@Component({
  imports: [XuiRadioImports],
  // …
})

Examples

Default

Loading preview…

Horizontal

Loading preview…

Disabled

Loading preview…

API

XuiRadioGroup

componentxui-radio-group

A single-choice group of radios.

Inputs

NameTypeDefaultclassClassValueThe user-defined classes. Merged last so they win over the base classes.''orientation'vertical' | 'horizontal'Layout of the options.this.config.orientationnamestringThe shared name for the radios in the group, so the browser treats them as one set. Defaults to a generated unique name.uniqueId('xui-radio-group')ariaLabelstring | nullAccessible name for the group — what is being chosen.nullariaLabelledbystring | nullId of an element naming the group. Use it instead of aria-label when that text is already on screen.nullvaluetwo-wayT | nullThe chosen value. Works two-way and via ngModel/formControl.nulldisabledbooleanDisable every radio in the group at once.false

Methods

select(value: T): voidisFirstEnabled(value: T): booleanWhich option holds the single tab stop: the selected one, or — when nothing is selected yet — the first enabled option, so Tab always lands somewhere.

XuiRadio

componentxui-radio

One option within a xui-radio-group.

Variants

AxisOptionsDefaultsizemdsmmd

Inputs

NameTypeDefaultclassClassValueThe user-defined classes. Merged last so they win over the variant classes.''sizeXuiRadioVariants['size']Button size, from the shared control scale.this.config.sizevaluerequiredTWhat the group's value becomes when this radio is chosen. Must be unique within the group.disabledbooleanDisable this radio alone. A radio in a disabled group is disabled regardless.false

Methods

focus(): void

Source

libs/ui/radio/xui

xUI 2.0.0 — Apache 2.0 licensed. Built with Angular and Tailwind CSS.