Skip to content

Switch 开关 ​

即时切换启用或停用状态

交互示例 ​

查看用法代码
vue
<script setup lang="ts">
import { ZSwitch } from '@codex-proxy/ui'
import { ref } from 'vue'

const enabled = ref(true)
</script>

<template>
  <ZSwitch v-model="enabled" label="启用配置" active-text="开" inactive-text="关" inline-prompt />
</template>

使用要点 ​

通过 active-text、inactive-text 描述状态,inline-prompt 将文字放入开关内部

API ​

属性 ​

属性类型默认值说明
v-modelbooleanfalse开关状态
labelstring—可见标签;隐藏标签使用 aria-label
active-text / inactive-textstring''开启与关闭文字
inline-promptbooleanfalse在开关内部显示状态文字
widthstring | number''轨道宽度,数字按 px 处理
disabledbooleanfalse禁止修改

事件 ​

事件说明
update:modelValueboolean,绑定值变化