Skip to content

Switch ​

Drawn with view on the Mini Program

The native switch component has uncontrollable styles on the Mini Program, so the thumb is drawn with view to keep the visuals consistent.

Basic usage ​

vue
<template>
  <lh-switch v-model="on" />
  <lh-switch v-model="on" active-text="On" inactive-text="Off" />
  <lh-switch v-model="on" loading />
  <lh-switch v-model="on" disabled />
</template>

<script setup lang="ts">
import { ref } from 'vue'
const on = ref(true)
</script>

Props ​

PropDescriptionTypeDefault
modelValue (v-model)Whether it is onbooleanfalse
disabledDisabledbooleanfalse
loadingLoadingbooleanfalse
nameNative namestring—
sizeSize'small' | 'medium' | 'large'—
activeTextText for the on statestring—
inactiveTextText for the off statestring—
customClassCustom class namestring—
sxQuick layout propsLhSxProps—

Events ​

EventDescriptionCallback parameters
update:modelValueValue changed(value: boolean)
changeValue changed(value: boolean)