VDS

Switch

Toggle between on and off states.

Installation

pnpm install @vds-testing/react @vds-testing/styles
pnpm install @vds-testing/elements @vds-testing/styles

See Installation for CSS setup.

Usage

React:

import { Switch } from "@vds-testing/react"
<Switch id="mode" />

Web Components:

<script type="module">
  import "@vds-testing/elements";
</script>
<vds-switch id="mode"></vds-switch>

Examples

Checked

Disabled

With description

Receive emails about new products and updates.

Anatomy

  • Switch - A single toggle element

Props

Switch

Prop Type Default Description
id string - Element ID for label association
name string - Form field name
checked boolean false Controlled checked state (React)
defaultChecked boolean false Uncontrolled initial state (React)
disabled boolean false Disables the switch
onCheckedChange (checked: boolean) => void - React callback when the value changes
class / className string - Additional CSS classes

Focus uses focus-shape (yellow/black outline) for the track.