Trên trang này

Alert

Cài đặt, prop và các phần tạo nên Alert.

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/alert.json

Cách dùng

<script setup lang="ts">
import { TriangleAlert } from '@lucide/vue'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
</script>

<template>
  <Alert variant="warning" role="status">
    <TriangleAlert />
    <AlertTitle>Số tồn kho đã cũ 2 giờ</AlertTitle>
    <AlertDescription>Kết nối kho đang chậm.</AlertDescription>
  </Alert>
</template>

Prop

Phần Prop Giá trị Ghi chú
Alert variant default, info, success, warning, destructive, danger danger giống destructive
Alert role alert (mặc định), status, note alert được đọc ngay; dùng status cho banner có sẵn từ đầu
AlertTitle, AlertDescription class chuỗi
AlertAction class chuỗi Chứa một nút nhỏ, trong cột riêng ở cuối

Icon đặt làm phần tử con đầu tiên của Alert có cột riêng, size.icon.default và màu của vai.

Dựng từ

Phần tử HTML thường và class-variance-authority, theo API Alert của control-center. Beehexa thêm các vai trạng thái, tên gọi khác danger và một cột lưới cho thao tác (bản gốc đặt nút theo vị trí tuyệt đối, nhãn dài bị tràn).