Skip to content
On this page

Switch

When To Use

  • If you need to represent the switching between two states or on-off state.
  • The difference between Switch and Checkbox is that Switch will trigger a state change directly when you toggle it, while Checkbox is generally used for state marking, which should work in conjunction with submit operation.

TIP

This component fully supports Switch component attribute of ant design

Examples

<template>
    <h-switch  v-model:checked="checked" :save-options="{autoSave:true,key:'checked'}" />
</template>
  
<script setup lang="ts">
    import { ref } from 'vue';
  
    const checked = ref<boolean>(false);
</script>
  

API

Props

PropertyDescriptionTypedefault
saveOptionsAutomatically upload and initialize component data.
Note ⚠️: Multiple key values under the same tool need to be unique.
objectautoSave:false,key:""