Skip to content

Checkbox ​

A checkbox for a consent or a setting.

The order cannot be placed without it

Pass the text in the default slot or in label. The hint and the error work as on the Field page.

Installation ​

ts
import { NuiCheckbox, NuiCheckboxGroup } from '@numior/kit';

Usage ​

Change the size and the states of the checkbox.

size
Changes the size of the control: sm, md or lg. The theme density shifts the height of each size.

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

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

Default slot text

Examples ​

Pick several options ​

Pass the options to the group in options.

Delivery methods

The customer picks one of them at checkout

The checked values come to v-model:values as an array. An option with disabled: true cannot be changed, and a checked one stays in the array.

Line the checkboxes up in a row ​

Set orientation="horizontal".

Delivery days

Check part of a list ​

Turn on indeterminate when only some items are checked.

Accessibility ​

The checkbox is a native <input type="checkbox">, so the keyboard and screen readers handle it as usual. The group is a <fieldset>, and its label is the <legend>.

Keys
Action
Space
Checks or unchecks the box.

API ​

NuiCheckbox

Props

Name
Type
Default
Description
indeterminate
boolean
false
Shows a dash instead of a check: some nested items are selected. A click clears it.
value
string
—
Value sent with the form when the box is checked.
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
boolean
false
Whether the checkbox is checked.

Slots

Name
Slot props
Description
default
{}
Label next to the checkbox.

NuiCheckboxGroup

Props

Name
Type
Default
Description
optionsrequired
readonly NuiOption<T>[]
—
Choices as objects with value, label and disabled.
name
string
—
The name attribute of every checkbox in the group, for form submission.
orientation
NuiCheckboxGroupOrientation
"vertical"
Layout: a column (vertical) or a row (horizontal).
getKey
NuiOptionKey<T>
—
Function that returns the key of an object value. 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:values
T[]
[]
Array of selected values in the order they were checked.

Slots

Name
Slot props
Description
option
{ option: NuiOption<T>; }
Custom choice label. Receives option.

Edit this page

Search

Esc