Radio group

A list of native radio buttons for picking exactly one of a few options that should all stay visible. For a long list use a select; for a compact segmented look use a select button.

  • vig-radio-group
  • ng-template[vigSelectOption]
Import
import { RadioGroup } from '@vigdx/ui/radio-group';
import { SelectOptionTemplate } from '@vigdx/ui/select';

Basic

Pass options as SelectOption objects ( value , label , optional icon and disabled ) and bind [(value)] . Values are compared with === ; the value is null while nothing is chosen.

Plan

You can change plans at any time.

Selected: team

Horizontal

orientation="horizontal" lays the options out in a wrapping row. An option with disabled: true is skipped by the arrow keys.

Shipping

Custom option template

An <ng-template vigSelectOption let-option> replaces the default icon and label of each option, here with a second line of detail. The text stays inside the radio's label.

Plan

Disabled, read-only and error

disabled disables every radio. readonly keeps them focusable but puts the checked state back after each change. Errors show once the group is touched and invalid .

Disabled

Read-only

Plan

Choose a plan.

Reactive Forms

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . The group counts as touched once focus leaves all of its radios.

Plan

{
  "plan": null
}

Signal Forms

vig-radio-group implements FormValueControl<T | null> , where T is the type of the option values.

Plan

Billing

Valid: no · no plan, monthly

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="radio-group"][data-part="group"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="radio-group"]

RadioGroup styling hooks
Part Element data-state
group The <fieldset role="radiogroup"> . —
label The <legend> . —
options Layout wrapper of the options. —
option One option <label> . checked, unchecked
control Wrapper of the radio circle and its dot. —
input The native radio (the visible circle). —
indicator The dot of the checked option. —
option-label The option text (without a custom option template). —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • Native <input type="radio"> elements share one name (generated when you do not set one), so the group is a single tab stop and the arrow keys move and select, mirrored under right-to-left.
  • The options sit in a native <fieldset> whose <legend> is the visible label; it keeps role="radiogroup" for the group states below. Without a visible label, pass ariaLabel.
  • required, readonly and an invalid state set aria-required, aria-readonly and aria-invalid on the group; hint and error are linked through aria-describedby.
  • Each option label is a <label> around its radio, so clicking the text selects the option, also with a custom template.

API

RadioGroup

vig-radio-group component

Classic radio list for an exclusive choice among a handful of visible options. Each option is a native <input type="radio"> sharing one name, so arrow keys, the single tab stop and form semantics come from the browser. For a compact segmented look use vig-select-button.

RadioGroup props
Name Type Default Description
ariaLabelstring | undefinedundefined
—
dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hintstring | undefinedundefined
—
invalidbooleanfalse
—
labelstring''

Visible group label; omit it and pass ariaLabel when a heading names the group.

namestring''
—
optionsreadonly SelectOption<T>[][]
—
orientationRadioGroupOrientation'vertical'
—
pendingbooleanfalse
—
readonlybooleanfalse
—
requiredbooleanfalse
—
touchedbooleanfalse
—
value model T | nullnull
—

SelectOptionTemplate

ng-template[vigSelectOption] directive

Custom rendering for options of vig-select, vig-multi-select, vig-listbox and vig-select-button, replacing the default icon + label. vig-select also uses it for the selected value shown in the trigger.

Bind the same options to vigSelectOptionOf (like ngForOf) to type let-option in the template; without it the option value is unknown.

Example :
<vig-select label="Status" [options]="statuses">
  <ng-template vigSelectOption [vigSelectOptionOf]="statuses" let-option>
    <i [class]="option.value" aria-hidden="true"></i> {{ option.label }}
  </ng-template>
</vig-select>
SelectOptionTemplate props
Name Type Default Description
vigSelectOptionOfreadonly SelectOption<T>[] | null | undefinedundefined

Type-only: the options the template renders, so the template type checker infers the option value type. Not read at runtime.

VigValueAccessor

directive

Bridges the vigdx form fields to Reactive Forms (formControl, formControlName) and template-driven forms (ngModel). Import it next to the component; Signal Forms ([formField]) need no accessor.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Are you sure?