Mỗi ví dụ là một file Vue hoàn chỉnh. Chép vào ứng dụng đã cài registry, hoặc mở trong StackBlitz. Bấm một nút, hoặc Tab tới nó rồi nhấn Enter.
Biểu mẫu ngắn
Hai ô và hai nút. Hủy đứng trước, thao tác chính ở cuối bên phải (D10). Biểu mẫu gửi khi nhấn Enter.
DialogEditConnection.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
// Một biểu mẫu ngắn trong dialog. Hủy đứng trước Lưu; Lưu ở cuối, bên phải (D10).
const open = ref(false)
const name = ref('Cửa hàng online – EU')
const url = ref('https://shop.example.com')
function save() {
open.value = false
}
</script>
<template>
<Dialog v-model:open="open">
<DialogTrigger as-child>
<Button variant="outline">Sửa kết nối</Button>
</DialogTrigger>
<DialogContent close-label="Đóng">
<form class="contents" @submit.prevent="save">
<DialogHeader>
<DialogTitle>Sửa kết nối</DialogTitle>
<DialogDescription>Thay đổi có hiệu lực từ lần đồng bộ tới. Đơn hàng đã đồng bộ giữ nguyên tên cửa hàng.</DialogDescription>
</DialogHeader>
<div class="grid gap-(--bh-space-200)">
<div class="grid gap-(--bh-space-050)">
<Label for="connection-name">Tên</Label>
<Input id="connection-name" v-model="name" autocomplete="off" />
</div>
<div class="grid gap-(--bh-space-050)">
<Label for="connection-url">Địa chỉ cửa hàng</Label>
<Input id="connection-url" v-model="url" type="url" autocomplete="off" />
</div>
</div>
<DialogFooter>
<DialogClose as-child>
<Button variant="outline">Hủy</Button>
</DialogClose>
<Button type="submit">Lưu thay đổi</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
</template>Chỉ có thông tin
Không có gì để lưu, nên footer chỉ có một nút Đóng (show-close-button). Giá trị chỉ đọc là chữ, không phải ô nhập.
DialogDetails.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
// Chỉ để xem, nên chân dialog có một nút Đóng. Giá trị chỉ đọc là chữ, không đặt trong ô nhập.
const webhook = [
{ label: 'Sự kiện', value: 'order.created' },
{ label: 'Địa chỉ nhận', value: 'https://erp.example.com/hooks/orders' },
{ label: 'Lần gửi gần nhất', value: '10:42, 12/11/2026 · 200 OK' },
]
</script>
<template>
<Dialog>
<DialogTrigger as-child>
<Button variant="outline">Xem webhook</Button>
</DialogTrigger>
<DialogContent close-label="Đóng">
<DialogHeader>
<DialogTitle>Webhook đơn hàng</DialogTitle>
<DialogDescription>Cửa hàng online gọi địa chỉ này mỗi khi có đơn hàng mới.</DialogDescription>
</DialogHeader>
<dl class="m-0 grid gap-(--bh-space-150) [&_dd]:m-0">
<div v-for="row in webhook" :key="row.label" class="grid gap-(--bh-space-025)">
<dt class="text-(--bh-color-text-subtle) [font:var(--bh-font-label-small)]">{{ row.label }}</dt>
<dd class="break-all text-(--bh-color-text) [font:var(--bh-font-code-default)]">{{ row.value }}</dd>
</div>
</dl>
<DialogFooter show-close-button close-label="Đóng" />
</DialogContent>
</Dialog>
</template>Nội dung dài
DialogScrollContent: khi dialog cao hơn cửa sổ, cả dialog cuộn trong lớp phủ, nên header và footer không bao giờ bị cắt.
DialogLongContent.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogScrollContent, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
// Nội dung có thể cao hơn màn hình: lớp nền cuộn cả dialog, kể cả phần đầu và chân.
const sections = [
{ title: 'Dữ liệu được xử lý', text: 'Bản ghi đơn hàng, khách hàng và sản phẩm mà cửa hàng online và ERP trao đổi khi đồng bộ.' },
{ title: 'Mục đích xử lý', text: 'Chỉ để chép các bản ghi đó giữa hai hệ thống bạn đã kết nối, theo lịch bạn đặt.' },
{ title: 'Nơi lưu', text: 'Bản ghi đi qua dịch vụ đồng bộ và không được lưu lại sau mỗi lần chạy, trừ nhật ký của lần chạy đó.' },
{ title: 'Thời gian giữ nhật ký', text: 'Nhật ký đồng bộ được giữ 30 ngày để bạn chạy lại lần bị lỗi, sau đó bị xóa.' },
{ title: 'Ai xem được', text: 'Người trong workspace có vai trò Admin hoặc Operator, và nhân viên hỗ trợ bạn mời vào một yêu cầu hỗ trợ.' },
{ title: 'Chấm dứt thỏa thuận', text: 'Ngắt kết nối cả hai hệ thống thì việc xử lý dừng ngay. Nhật ký bị xóa trong vòng 30 ngày.' },
]
</script>
<template>
<Dialog>
<DialogTrigger as-child>
<Button variant="outline">Đọc thỏa thuận</Button>
</DialogTrigger>
<DialogScrollContent close-label="Đóng">
<DialogHeader>
<DialogTitle>Thỏa thuận xử lý dữ liệu</DialogTitle>
<DialogDescription>Đọc trước khi kết nối ERP. Bạn có thể xem lại trong Cài đặt › Pháp lý.</DialogDescription>
</DialogHeader>
<section v-for="section in sections" :key="section.title" class="grid gap-(--bh-space-050)">
<h3 class="m-0 text-(--bh-color-text) [font:var(--bh-font-heading-xsmall)]">{{ section.title }}</h3>
<p class="m-0 text-(--bh-color-text-subtle)">{{ section.text }}</p>
</section>
<DialogFooter>
<DialogClose as-child>
<Button variant="outline">Để sau</Button>
</DialogClose>
<DialogClose as-child>
<Button>Tôi đồng ý</Button>
</DialogClose>
</DialogFooter>
</DialogScrollContent>
</Dialog>
</template>