The Examples tab shows the switch as plain HTML and CSS. In a Vue app with shadcn-vue, install the registry component instead: it draws the same switch from the same switch.* tokens.
Install
Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):
npx shadcn-vue@latest add https://beehexa.design/r/switch.json
Props
| Prop | Values | Notes |
|---|---|---|
v-model |
boolean | On or off |
size |
default, sm |
|
disabled |
boolean | Disabled colours, never opacity |
Settings that apply at once
SwitchSettings.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Switch } from '@/components/ui/switch'
const settings = ref([
{ id: 'sync-orders', label: 'Sync orders automatically', on: true },
{ id: 'sync-stock', label: 'Update stock every 15 minutes', on: false },
{ id: 'email-failures', label: 'Email me when a sync fails', on: true },
])
</script>
<template>
<ul class="m-0 grid list-none gap-(--bh-space-150) p-0">
<li v-for="setting in settings" :key="setting.id" class="flex items-center gap-(--bh-space-100)">
<Switch :id="setting.id" v-model="setting.on" />
<label :for="setting.id" class="text-(--bh-color-text) [font:var(--bh-font-body-default)]">{{ setting.label }}</label>
</li>
</ul>
</template>Disabled
Turn on order sync first.
Only a workspace admin can change this.
SwitchDisabled.vue
<script setup lang="ts">
import { Switch } from '@/components/ui/switch'
</script>
<template>
<div class="grid gap-(--bh-space-150)">
<div class="grid gap-(--bh-space-050)">
<div class="flex items-center gap-(--bh-space-100)">
<Switch id="sync-inventory" disabled aria-describedby="sync-inventory-why" />
<label for="sync-inventory" class="text-(--bh-color-text-disabled) [font:var(--bh-font-body-default)]">Sync inventory</label>
</div>
<p id="sync-inventory-why" class="m-0 text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">Turn on order sync first.</p>
</div>
<div class="grid gap-(--bh-space-050)">
<div class="flex items-center gap-(--bh-space-100)">
<Switch id="sync-orders-locked" :model-value="true" disabled aria-describedby="sync-orders-locked-why" />
<label for="sync-orders-locked" class="text-(--bh-color-text-disabled) [font:var(--bh-font-body-default)]">Sync orders</label>
</div>
<p id="sync-orders-locked-why" class="m-0 text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">Only a workspace admin can change this.</p>
</div>
</div>
</template>Built on
reka-ui SwitchRoot and SwitchThumb, as the shadcn-vue Switch.