Switch
Switch turns a setting on or off right away, with no save step. Pair it with a Label so the label text is clickable too. For a choice that waits for a Save button, use Checkbox.
This example also needs: Label.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Examples
Checked
Set defaultChecked to start the switch in the on position.
Disabled
A disabled switch shows muted colors and ignores clicks.
Small
Set size="sm" for dense rows.
Label on left
Put the label and description on the left of a settings row.
Receive emails about new products and features.
Props
Switch
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | null | "default" | No description |
Switch turns a setting on or off right away, with no save step. Pair it with a label so the label text is clickable too.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/switch/Switch.vue components/switch/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Checked
Set default-value to start the switch in the on position.
Disabled
A disabled switch shows muted colors and ignores clicks.
Small
Set size="sm" for dense rows.
Label on left
Put the label and description on the left of a settings row.
Props
Switch
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | null | "default" | No description |