Cài đặt
Chạy lệnh này trong app, sau shadcn-vue init và theme Beehexa (Button › Code):
npx shadcn-vue@latest add https://beehexa.design/r/drawer.json
Cách dùng
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import {
Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger,
} from '@/components/ui/drawer'
</script>
<template>
<Drawer>
<DrawerTrigger as-child>
<Button variant="outline">Lịch đồng bộ</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Lịch đồng bộ</DrawerTitle>
<DrawerDescription>Bao lâu thì đơn hàng chuyển sang ERP một lần.</DrawerDescription>
</DrawerHeader>
<!-- body: px-(--bh-space-modal) -->
<DrawerFooter>
<DrawerClose as-child><Button variant="outline">Hủy</Button></DrawerClose>
<Button>Lưu</Button>
</DrawerFooter>
</DrawerContent>
</Drawer>
</template>
Prop
| Phần | Prop | Giá trị | Ghi chú |
|---|---|---|---|
Drawer |
open, defaultOpen |
boolean | Trạng thái điều khiển (v-model:open) hoặc ban đầu |
Drawer |
swipeDirection |
down (mặc định), up, left, right |
Cạnh mà drawer đi ra và được vuốt về. Chỉ down có thanh kéo |
Drawer |
snapPoints, snapPoint |
số hoặc chuỗi | Các độ cao drawer dừng lại |
Drawer |
modal |
boolean | Mặc định true: không dùng được trang phía sau |
DrawerTrigger, DrawerClose |
as-child |
boolean | Nên dùng, để trigger chính là Button của bạn |
Dựng trên
Drawer của reka-ui, với API Drawer của shadcn-vue. reka-ui lo role="dialog", aria-modal, giữ focus, xử lý thao tác vuốt và phím Esc. Beehexa thêm kiểu dáng.
Giới hạn
- Chuyển động trượt dùng thời gian của shadcn-vue (500 ms, đường cong kiểu lò xo), chưa dùng token motion.