Skip to content

Radio group ​

A choice of one option from a few that are all in view.

Payment method

You can change it until the order ships

Give every NuiRadio a value, and the v-model of the group holds the value of the checked one.

Installation ​

ts
import { NuiRadio, NuiRadioGroup } from '@numior/kit';

Usage ​

Lay the radios out in a row and change the size and the states of the group.

Delivery method
orientation
Lays out the radios in a column or a row.
size
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.

Label of the control. Inside NuiField the field provides the label.

Hint below the control. Screen readers announce it with the control.

Error text below the control. Puts the control into the error state.

Examples ​

Keep an object in the model ​

Pass an object to value.

Shipping warehouse

The order is packed at BOS-1, Boston

The group matches a radio to the model by the key of its value, which is the JSON of the object by default. When the object comes back from the server with changed fields, return its id from getKey.

Accessibility ​

The radios are native, so the arrow keys move the choice and a form submits the value under the shared name. A screen reader reads the label, the hint and the error of the group when the focus enters it.

disabled on the group turns off every radio, and on a NuiRadio only that one.

Keys
Action
↓
Selects the next radio.
↑
Selects the previous radio.
Space
Selects the focused radio.

API ​

NuiRadioGroup

Props

Name
Type
Default
Description
name
string
—
Name the selected value is submitted with in a form.
orientation
NuiRadioGroupOrientation
"vertical"
Lays out the radios in a column or a row.
options
readonly NuiOption<T>[]
—
Options to choose from. The radios are built from them instead of the slot.
getKey
NuiOptionKey<NonNullable<T>>
—
Function that returns the key of an object value; the selected radio is found by this key. Without it the JSON of the value is the key.
id
string
—
Id of the control. Defaults to the one from NuiField or is generated automatically.
size
NuiSize
"md"
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.
disabled
boolean
—
Disables the control. Inside NuiField it defaults to the field value.
readonly
boolean
—
Prevents changes to the value, which stays selectable and copyable. Inside NuiField it defaults to the field value.
required
boolean
—
Marks the control as required. Inside NuiField it defaults to the field value.
invalid
boolean
—
Shows the error state without a text. With error it turns on by itself.
label
string
—
Label of the control. Inside NuiField the field provides the label.
description
string
—
Hint below the control. Screen readers announce it with the control.
error
string
—
Error text below the control. Puts the control into the error state.
reserveError
boolean
false
Reserves space for the error so the form does not shift when it appears.

Models

Name
Type
Default
Description
v-model
T
—
Value of the selected radio.

Slots

Name
Slot props
Description
default
{}
NuiRadio buttons.
option
{ option: NuiOption<T>; }
Label of a radio built from options.

NuiRadio

Props

Name
Type
Default
Description
valuerequired
T
—
Value the group v-model receives.
id
string
—
Id of the radio. Generated automatically by default.
disabled
boolean
—
Disables one radio while the others in the group keep working.

Slots

Name
Slot props
Description
default
{}
Label of the radio.

Edit this page

Search

Esc