CSC Design System next
VueFlavour Vue React Angular TypeScript PrimaryCSC UI ColorsPrimarySecondaryAccentCustom ColorsRedOrangeGreenBluePurplePink
Guides Getting started Customization Data visualization Migration guide Componentsc-accordionc-alertc-autocompletec-badgec-buttonc-button-groupc-cardc-checkboxc-csc-logoc-data-tablec-dividerc-iconc-icon-buttonc-inputc-linkc-listc-loaderc-login-buttonsc-login-cardc-mainc-menuc-messagec-modalc-navigation-buttonc-otp-inputc-pagec-paginationc-popoverc-progress-barc-progress-circlec-radio-groupc-selectc-side-navigationc-sliderc-spinnerc-statusc-stepsc-switchc-tablec-tabsc-tagsc-text-fieldc-toastsc-toolbarc-tooltip

<c-switch>

A toggle for a binary setting that takes effect immediately: a native switch control with a label, an optional hint, and validation messaging.

Usage

Bind the state with a plain v-model (or the checked prop); true-value / false-value map the on/off state onto custom values.

<c-switch v-model="notifications">Email notifications</c-switch>

When to use

  • Turning a setting or mode on/off with immediate effect (no submit step).

When not to use

  • A choice that is collected and submitted with a form — use c-checkbox.

Customization

Restyle via CSS parts from your own stylesheet. The slider part is the toggle track (its ::before pseudo-element is the handle); the host exposes the checked custom state, so the track is stylable per state:

c-switch:state(checked)::part(slider) {
  background: var(--my-green);
}

c-switch:state(checked)::part(slider)::before {
  background: white;
}

For app-wide recolouring prefer the design tokens (--c-primary seed) over per-component rules.

Examples

Basic
Vue React Angular TypeScript
<template>
  <div class="example-grid">
    <c-switch v-model="enabled">Notifications</c-switch>

    <p>Value: {{ enabled }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const enabled = ref(false);
</script>
Label
Vue React Angular TypeScript
<template>
  <c-switch label="Email notifications" required />
</template>

API reference

<c-switch>

A toggle for a binary setting that takes effect immediately: a native switch control with a label, an optional hint, and validation messaging.

Properties

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseIf `true`, the checkbox is selected.
disableddisabledbooleanfalseIf `true`, the switch is disabled and cannot be toggled
falseValuefalse-valueboolean | number | stringfalseThe value when the checkbox is unchecked
hostIdhost-idstring''Id for the element
labellabelstring''Label of the switch, shown beside the toggle. Falls back to the default slot content when not set.
loadingloadingbooleanfalseLoading state
requiredrequiredbooleanfalseSet as required
trueValuetrue-valueboolean | number | stringtrueThe value when the checkbox is checked
valuevalueboolean | number | stringfalseThe input value - Only used when the checkbox participates in a native `<form>`

Events

EventDetailDescription
changevoidStandard bubbling DOM change event, re-dispatched from the host when the switch is toggled (the inner input's change does not cross the shadow boundary). No detail; read the new value from the host's `value` property.
changeValueboolean | number | stringFired when the switch is toggled, carrying the new value — `trueValue` when on, `falseValue` when off. Also dispatched as `change-value` — bind that name in Vue templates.
inputvoidNative bubbling input event fired on toggle so a plain Vue `v-model` works without the `v-control` directive. No detail.
update:valueboolean | number | stringv-model contract event fired on toggle, carrying the new value — `trueValue` when on, `falseValue` when off.

Slots

SlotDescription
defaultThe visible label of the switch (fallback when the `label` prop is not set)

CSS parts

Style from outside with c-switch::part(name) — parts are the library's only styling customization API.

PartDescription
rootThe `<label>` element wrapping the toggle and the label text
sliderThe toggle track (its `::before` pseudo-element is the handle)
labelWrapper around the label text or slotted label content

Custom states

Select on the host's live state with c-switch:state(name) — combine with ::part() for per-state styling, e.g. c-switch:state(checked)::part(indicator).

StateDescription
checkedPresent while the switch is on