Formulários
VSwitch
Toggle binário on/off para configurações e preferências, com thumb animado e suporte a label/descrição.
<script setup lang="ts">
import { VSwitch } from 'vueui-nova-kit'
</script>Uso
<script setup lang="ts">
</script>
<template>
</template>Playground
Os controles abaixo são gerados a partir das props declaradas em VSwitch.types.ts; o código acompanha cada mudança.
Exemplos
Variantes, tamanhos e estados, extraídos das stories da biblioteca.
Default
Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo.
Ver código
<script setup lang="ts">
import { VSwitch } from 'vueui-nova-kit'
</script>
<template>
<VSwitch v-model="value" />
</template>On
Variação Em. Props: modelValue=true.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const value = ref(true)
</script>
<template>
<VSwitch v-model="value" />
</template>Labeled
Variação Labeled. Props: modelValue=true, label="Enable notifications", description="Get product updates and tip…".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const value = ref(true)
</script>
<template>
<VSwitch
v-model="value"
label="Enable notifications"
description="Get product updates and tips." />
</template>Settings Row
Variação Settings Row. Props: modelValue=true, label="Dark mode", description="A more comfortable viewing …", showIcon=true.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const value = ref(true)
</script>
<template>
<VSwitch
v-model="value"
label="Dark mode"
description="A more comfortable viewing experience."
show-icon />
</template>Disabled
Variação Desabilitado. Props: modelValue=true, disabled=true, label="Disabled switch", description="Cannot be changed.".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const value = ref(true)
</script>
<template>
<VSwitch
v-model="value"
disabled
label="Disabled switch"
description="Cannot be changed." />
</template>Sizes
Variação Tamanhos. Interativo: o estado é mantido na própria story (v-model).
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const sm = ref(true)
const md = ref(false)
const lg = ref(true)
</script>
<template>
<div style="display:flex;flex-direction:column;gap:16px;max-width:420px">
<VSwitch v-model="sm" size="sm" label="Small switch" />
<VSwitch v-model="md" size="md" label="Medium switch" />
<VSwitch v-model="lg" size="lg" label="Large switch" />
</div>
</template>States
Variação Estados. Interativo: o estado é mantido na própria story (v-model).
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const off = ref(false)
const on = ref(true)
</script>
<template>
<div style="display:flex;gap:24px;align-items:center;flex-wrap:wrap">
<VSwitch v-model="off" aria-label="Switch off" />
<VSwitch v-model="on" aria-label="Switch on" />
<VSwitch :model-value="false" disabled aria-label="Disabled off" />
<VSwitch :model-value="true" disabled aria-label="Disabled on" />
</div>
</template>Interactive
Variação Interativo. Estado mantido via v-model (ref no setup), com ícone de tema.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VSwitch } from 'vueui-nova-kit'
const dark = ref(false)
</script>
<template>
<VSwitch v-model="dark" label="Dark mode" description="A more comfortable viewing experience." showIcon />
</template>Acessibilidade
role="switch", Space/Enter para alternar, label visível, foco com anel de 2px, opacidade no disabled, área mínima 44×24px.
Estados
Off · Hover Off · Focus Off · On · Hover On · Focus On · Pressed · Disabled Off · Disabled On.
Motion
| Trigger | Property | Duration | Easing |
|---|---|---|---|
| Toggle | transform/background | 160ms | standard |
| Hover | box-shadow/tint | 100ms | ease-out |
| Focus ring | box-shadow | 120ms | ease-out |
| Pressed | thumb scale | 70ms | ease-in |
Respeitar prefers-reduced-motion.
Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.
Props
| Prop | Tipo | Default | Descrição |
|---|---|---|---|
modelValue | boolean | false | — |
label | string | — | — |
description | string | — | — |
disabled | boolean | false | — |
size | VSwitchSize | "md" | — |
name | string | — | — |
id | string | — | — |
showIcon | boolean | false | — |
ariaLabel | string | — | — |
motion | VMotionLevel | V_MOTION_DEFAULT ("expressive") | — |
Events
| Evento | Payload | Descrição |
|---|---|---|
@update:modelValue | value: boolean | — |
@change | value: boolean | — |
Slots
| Slot | Props do slot |
|---|---|
#label | — |
Fonte: src/components/form/VSwitch/VSwitch.vue · tipos: src/components/form/VSwitch/VSwitch.types.ts