Back to components
ComponentsSwitch
Standalone switch control for capturing boolean input, usable independently or within custom form layouts.
Component
Props
| Props | Required | Default | Type |
|---|---|---|---|
id | true | — | string |
modelValue | — | false | boolean |
disabled | — | false | boolean |
size | — | ControlFieldSize.MD | ControlFieldSize |
styleType | — | SwitchStyle.BRAND | SwitchStyle |
Usage
id
Sets the id of the underlying native checkbox input.
<template>
<Switch id="my-switch" />
</template>
modelValue
Controls the checked state of the switch. Use v-model for two-way binding.
<template>
<Switch id="my-switch" v-model="isEnabled" />
</template>
<script setup lang="ts">
const isEnabled = ref(false)
</script>
disabled
Sets the disabled state of the switch. When disabled, clicks are ignored and the switch appearance reflects the inactive state.
<template>
<Switch id="my-switch" disabled />
</template>
size
Sets the size of the switch. It uses the ControlFieldSize enum.
<template>
<Switch id="my-switch" :size="ControlFieldSize.LG" />
</template>
Options
| Value | Description |
|---|---|
XS | Extra Small |
SM | Small |
MD | Medium |
LG | Large |
styleType
Sets the style type of the switch. It uses the SwitchStyle enum.
<template>
<Switch id="my-switch" :styleType="SwitchStyle.SUCCESS" />
</template>
Options
| Value | Description |
|---|---|
BRAND | Uses the primary brand color for the background when the switch is on. |
SUCCESS | Uses the success color for the background when the switch is on. |