Trên trang này

Toggle button

Cài đặt, props và các phần tạo nên Toggle button.

Cài đặt

Chạy trong app, sau shadcn-vue init và theme Beehexa (Nút › Code):

npx shadcn-vue@latest add https://beehexa.design/r/button.json
npx shadcn-vue@latest add https://beehexa.design/r/toggle.json

Cách dùng

<script setup lang="ts">
import { Pin } from '@lucide/vue'
import { ref } from 'vue'
import { Toggle } from '@/components/ui/toggle'

const pinned = ref(true)
</script>

<template>
  <div class="flex items-center gap-(--bh-space-100)">
    <Toggle v-model="pinned" variant="outline"><Pin />Ghim</Toggle>
    <Toggle><Pin />Ghim</Toggle>
    <Toggle variant="outline" disabled><Pin />Ghim</Toggle>
  </div>
</template>

Props

Prop Giá trị Ghi chú
v-model (modelValue) boolean Bật hoặc tắt
variant default, outline Nút Nhẹ hoặc Mặc định
size Cỡ của Button sm, default, lg, icon-sm, icon, icon-lg
disabled boolean

Dựng từ

Bọc Toggle của reka-ui với API Toggle của shadcn-vue và style của Button.