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/command.json
Lệnh này cũng cài Dialog và Input group.
Cách dùng
<script setup lang="ts">
import {
Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList,
} from '@/components/ui/command'
</script>
<template>
<Command>
<CommandInput placeholder="Tìm trang và thao tác" />
<CommandList>
<CommandEmpty>Không có kết quả phù hợp.</CommandEmpty>
<CommandGroup heading="Đi tới">
<CommandItem value="orders">Đơn hàng</CommandItem>
<CommandItem value="products">Sản phẩm</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</template>
Prop
| Phần | Prop | Giá trị | Ghi chú |
|---|---|---|---|
Command |
v-model |
string hoặc mảng | value của mục được chọn. Phần lớn bảng lệnh chỉ dùng @select |
Command |
multiple |
boolean | Chọn được nhiều mục; mỗi mục được chọn có dấu check |
CommandDialog |
open |
boolean | v-model:open |
CommandDialog |
title, description |
string | Cho trình đọc màn hình. Đặt theo ngôn ngữ của trang |
CommandDialog |
showCloseButton |
boolean, mặc định true |
Nút đóng của dialog |
CommandInput |
placeholder |
string | |
CommandGroup |
heading |
string | |
CommandItem |
value |
string | Bắt buộc, không trùng |
CommandItem |
disabled |
boolean | |
CommandItem |
@select |
sự kiện | Chạy thao tác |
Dựng trên
Listbox của reka-ui, với API Command của shadcn-vue như control-center đang dùng, cùng các component Dialog và Input group. reka-ui lo role="listbox", aria-activedescendant từ ô tìm kiếm, và các phím mũi tên. Bộ lọc là của control-center, dùng useFilter của reka-ui. Beehexa thêm kiểu dáng.