Immediate preference
Turn account notifications on or off as a persistent setting.
Components / Forms
A labelled on/off control built on a native checkbox.
npx @getweini/cli@latest add switchTurn account notifications on or off as a persistent setting.
Disable a preference that the current plan does not allow.
<script setup lang="ts">
import { ref } from 'vue'
import Switch from './components/ui/switch/Switch.vue'
import Label from './components/ui/label/Label.vue'
const alerts = ref(true)
</script>
<template>
<Switch id="alerts" v-model="alerts" />
<Label for="alerts">Notifications</Label>
</template>A stable label describes the setting in both states.
<script setup lang="ts">
import { ref } from 'vue'
import Switch from './components/ui/switch/Switch.vue'
import Label from './components/ui/label/Label.vue'
const alerts = ref(true)
</script>
<template>
<Switch id="alerts" v-model="alerts" name="alerts" value="enabled" />
<Label for="alerts">Email alerts</Label>
</template>Disable both control and related explanatory presentation.
<script setup lang="ts">
import { ref } from 'vue'
import Switch from './components/ui/switch/Switch.vue'
import Label from './components/ui/label/Label.vue'
const audit = ref(false)
</script>
<template>
<Switch id="audit" v-model="audit" disabled aria-describedby="audit-help" />
<Label for="audit" disabled>Audit log</Label>
<p id="audit-help">Available on the Team plan.</p>
</template>The most useful props, models, slots, events, and methods for this component.
| Name | Type | Default or requirement |
|---|---|---|
v-model | boolean | required |
size | sm | md | lg | md |
invalid | boolean | false |
Space and label activation work natively. Checked switches submit their value; unchecked switches submit nothing.