All skills
Skillintermediate
Component specification
A toggle control that allows users to switch between two states (on/off). The Switch component is ideal for binary choices where the effect is immediate, such as enabling or disabling a feature.
Claude Code Knowledge Pack7/10/2026
Overview
Component specification
A toggle control that allows users to switch between two states (on/off). The Switch component is ideal for binary choices where the effect is immediate, such as enabling or disabling a feature.
Public API Definition
Props
id?: string- The ID of the switch elementlabel?: string- Text label displayed to the right of the switchmodelValue?: boolean- The controlled checked state of the switch. Can be bound asv-modeldefaultValue?: boolean- The checked state of the switch when initially rendered. Use when you do not need to control the statedisabled?: boolean- Whentrue, prevents the user from interacting with the switchrequired?: boolean- Whentrue, indicates that the user must check the switch before submittingname?: string- The name of the switch for form submissionvalue?: string- The value given as data when submitted with a namesize?: 'small' | 'large'- The size of the switch. Defaults to'small'as?: string | Component- Change the default rendered element for the one passed as a child, merging their props and behavior
Events
change(event: Event)- Event fired when the switch value changesupdate:modelValue(value: boolean)- Event fired when the model value updates
Slots
label:{ label?: string }- Custom content for the label
Template usage example
<script setup lang="ts">
const isEnabled = ref(false)
</script>
<template>
</template>
<script setup lang="ts">
const sendBody = ref(false)
const timeout = ref(true)
</script>
<template>
</template>
<script setup lang="ts">
const isAccepted = ref(false)
</script>
<template>
<template #label>
I accept the <a href="/terms">terms and conditions</a>
</template>
</template>