Trên trang này

Sheet

Ví dụ chạy được của Sheet, kèm đúng file Vue tạo ra từng ví dụ.

Mỗi ví dụ là một file Vue hoàn chỉnh. Chép vào app đã cài registry, hoặc mở trong StackBlitz. Bấm nút để mở từng sheet.

Sửa một bản ghi

Một biểu mẫu ngắn. lg:max-w-md thu hẹp sheet theo biểu mẫu; các nút ở dưới cùng, Hủy trước và thao tác chính sau cùng.

SheetEditForm.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import {
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from '@/components/ui/sheet'

const open = ref(false)
const name = ref('Cửa hàng online chính')
const url = ref('https://shop.example.com')
</script>

<template>
  <Sheet v-model:open="open">
    <SheetTrigger as-child>
      <Button variant="outline">Sửa cửa hàng</Button>
    </SheetTrigger>
    <SheetContent class="lg:max-w-md" close-label="Đóng">
      <SheetHeader>
        <SheetTitle>Sửa cửa hàng</SheetTitle>
        <SheetDescription>Thay đổi có hiệu lực từ lần đồng bộ tới.</SheetDescription>
      </SheetHeader>
      <form id="edit-store" class="grid gap-(--bh-space-200) px-(--bh-space-modal)" @submit.prevent="open = false">
        <div class="grid gap-(--bh-space-050)">
          <Label for="store-name">Tên cửa hàng</Label>
          <Input id="store-name" v-model="name" />
        </div>
        <div class="grid gap-(--bh-space-050)">
          <Label for="store-url">URL cửa hàng</Label>
          <Input id="store-url" v-model="url" type="url" />
        </div>
      </form>
      <SheetFooter>
        <SheetClose as-child>
          <Button variant="outline">Hủy</Button>
        </SheetClose>
        <Button type="submit" form="edit-store">Lưu thay đổi</Button>
      </SheetFooter>
    </SheetContent>
  </Sheet>
</template>

Xem chi tiết một dòng

Sheet xem dữ liệu giữ chiều rộng mặc định: cả cửa sổ trên điện thoại, layout.overlay.default từ breakpoint.lg.

SheetOrderDetails.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import {
  Sheet,
  SheetContent,
  SheetDescription,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from '@/components/ui/sheet'

const fields = [
  { label: 'Khách hàng', value: 'Nguyễn An' },
  { label: 'Kênh', value: 'Cửa hàng online' },
  { label: 'Tổng tiền', value: '1.250.000 ₫' },
  { label: 'Trạng thái', value: 'Chờ đưa vào ERP' },
]
</script>

<template>
  <Sheet>
    <SheetTrigger as-child>
      <Button variant="ghost">Đơn #10482</Button>
    </SheetTrigger>
    <!-- A data-inspection sheet: full width on phones, layout.overlay.default from breakpoint.lg. -->
    <SheetContent close-label="Đóng">
      <SheetHeader>
        <SheetTitle>Đơn #10482</SheetTitle>
        <SheetDescription>Đặt ngày 12/11/2026, chưa có trong ERP.</SheetDescription>
      </SheetHeader>
      <dl class="grid grid-cols-[auto_1fr] gap-x-(--bh-space-300) gap-y-(--bh-space-100) overflow-y-auto px-(--bh-space-modal)">
        <template v-for="field in fields" :key="field.label">
          <dt class="text-(--bh-color-text-subtle)">{{ field.label }}</dt>
          <dd>{{ field.value }}</dd>
        </template>
      </dl>
    </SheetContent>
  </Sheet>
</template>