Switch
Toggle switch built with a checkbox input type.
Installation
Follow instructions for individual framework usage below
Styles
Variants
Props
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>