Skip to content

Switch ​

Toggle switch built with a checkbox input type.

View Source 

Installation ​

Follow instructions for individual framework usage below

  • winduum 
  • winduum-vue 
  • winduum-react 

Styles ​

Variants ​

  • default 
  • interactive 
  • invalid 

Props ​

  • default 
  • interactive 

Examples ​

Basic ​

html
<div class="x-switch">
    <input type="checkbox" id="checkbox">
    <label for="checkbox">Switch</label>
</div>
vue
<script setup lang="ts">
    import { Switch } from '@/components/switch'
</script>

<template>
    <Switch class="x-switch">
        <input type="checkbox">
        Switch
    </Switch>
</template>
jsx
import { Switch } from '@/components/switch'

export function Example() {
    return (
        <Switch class="x-switch">
            <input type="checkbox" />
            Switch
        </Switch>
    )
}

Small ​

html
<div class="x-switch sm" id="checkbox">
    <input type="checkbox">
    <label for="checkbox">Switch</label>
</div>

Large ​

html
<div class="x-switch lg">
    <input type="checkbox" id="checkbox">
    <label for="checkbox">Switch</label>
</div>

Disabled ​

html
<div class="x-switch">
    <input type="checkbox" id="checkbox" disabled>
    <label for="checkbox">Switch</label>
</div>

Validation ​

Invalid state styling via the invalid variant — works with native HTML5 form validation, see Form.

html
<div class="x-switch">
    <input type="checkbox" id="checkbox" required>
    <label for="checkbox">Switch</label>
</div>

Released under the MIT License.