@surstromming/switch

On/off switch over a native checkbox.
289
Install
npm install @surstromming/switch
Latest Version:0.1.0
Vue:3
License:MIT
Last Updated:Oct 17, 2026
Links: GitHub  ·  npm
Maintainer: evgeniy_mnatsakanov

@surstromming/switch

On/off switch — an immediate toggle (a setting that applies at once), unlike a Checkbox, which is a value you submit with a form.

A native <input type="checkbox" role="switch"> made invisible on top of a drawn track, so keyboard, click and forms stay native.

Dependency graph

graph LR
  switch["@surstromming/switch"]
  design["@surstromming/design"]
  switch --> design

Usage

<template>
  <Label for="airplane">
    <Switch id="airplane" v-model="airplaneMode" /> Airplane mode
  </Label>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Switch } from '@surstromming/switch'

const airplaneMode = ref(false)
</script>

Props

Prop Type Default Notes
v-model boolean — defineModel()

id · disabled · name · aria-* and everything else fall through to the inner <input> (inheritAttrs: false) — that's where a Label's for must point.

Anatomy

span.root          // 2rem × 1.25rem, positioning context
  ├─ input.input   // the real checkbox (role="switch"): invisible, on top
  └─ span.track    // painted track
       └─ span.thumb   // slides on :checked

States & tokens

State Track Thumb
resting input background
:checked primary slides right
:focus-visible ring border + 3px ring —
:disabled 50% opacity —

Pill radius; the thumb's slide honours prefers-reduced-motion.

Accessibility

role="switch" on a real checkbox: Space toggles it and screen readers announce "on"/"off" instead of "checked". Label it — a lone switch says nothing about what it turns on.

Related Packages

@surstromming/popover

Panel anchored under a trigger; closes on outside click and Escape.

1,481 0
@surstromming/dialog

Modal dialog, with an alert-dialog mode and sheets on the screen's edges.

1,382 0
@surstromming/design

Everything related to design system, including colors, typography, and spacing.

1,363 0
@surstromming/scroll-area

A scroll container with an Edge-style overlay scrollbar.

1,157 0

Version History

Version Released Vue License
0.1.0 ^3.4.0 MIT