Toggle
Toggle is a button that stays pressed until clicked again, such as Bold. Icon-only toggles need an aria-label. For a set of related toggles, use ToggleGroup.
This example also needs:
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Examples
Variants
Pick default, outline or outline-primary for the border style.
Sizes
Set size to sm, default or lg.
With text
Put an icon and a text label in the same toggle.
Disabled
A disabled toggle shows muted colors and ignores clicks.
Controlled
Drive the pressed state with pressed and onPressedChange.
Props
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "lg" | null | "default" | No description |
variant | "default" | "outline" | "outline-primary" | null | "default" | No description |
Toggle is a button that stays pressed until clicked again, such as Bold. Icon-only toggles need an aria-label. For a set of related toggles, use ToggleGroup.
This example also needs:
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/toggle/Toggle.vue components/toggle/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
Variants
Pick default, outline or outline-primary for the border style.
Sizes
Set size to sm, default or lg.
With text
Put an icon and a text label in the same toggle.
Disabled
A disabled toggle shows muted colors and ignores clicks.
Controlled
Drive the pressed state with v-model.
Props
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
size | "default" | "sm" | "lg" | null | "default" | No description |
variant | "default" | "outline" | "outline-primary" | null | "default" | No description |