Skip to content

Switch ​

A toggle for a setting that takes effect at once.

Customers see them in the catalog marked as out of stock

For a choice that applies only after the form is submitted, use a Checkbox.

Installation ​

ts
import { NuiSwitch } from '@numior/kit';

Usage ​

Change the size and the states of the switch.

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 ​

Build a list of settings ​

Explain in description what the switch changes.

An email to the manager once the order is paid

An email and a notice in the dashboard

A digest of reviews once a day, at 9 a.m.

Accessibility ​

The switch is a native checkbox with the switch role, so a screen reader announces it as on or off and reads the label. In right-to-left text the knob moves the other way.

Keys
Action
Space
Toggles the state.

API ​

Props

Name
Type
Default
Description
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 switch is on.

Slots

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

Edit this page

Search

Esc