Skip to content
Vy logo
  • Identitet
  • Spor
  • Resources
Components

Switch

Switches let the users choose between yes or no.

FigmaGitHub

Code examples

<Switch />

Guidelines

Switches are a component you use to turn a given feature, service, or setting on or off. You can think of them as a slightly more explicit version of a checkbox.

Instructions for use

A switch should always have a label that indicates what it controls. The label should be static, and should not change based on what state the switch is in (on or off). For example, instead of having a dynamic label such as “Turn off push notification“ and “Turn on push notifications“, use “Send push notifications“ that should be shown regardless of whether the swtich is on or off.

Toggling a switch should give immediate effect, and the user should not need to click on a “Save“-button after toggling the Switch to see the effect.

Code

<Switch />

import { Switch } from "@vygruppen/spor-react";

Lets the user turn something on or off

Props

Name
Type
Required?
Description
size"sm" | "md" | "lg"Default "md"
checkedboolean
disabledboolean
invalidboolean
defaultCheckedboolean
onCheckedChange(details: CheckedChangeDetails) => void
labelstring
namestring
asstringEffects the container for the Switch.