跳转到内容

警告提示 ​

基于 zw-alert 基础组件构建的样式化警告提示组件族。

@zeus-web/alert反馈zweb add alert自动生成

交互演示 ​

源码 ​

请选择与你的应用框架匹配的入口。

html
<script type="module">
  import '@zeus-web/alert/wc/auto'
</script>

<zw-alert variant="success">
  <zw-alert-title>Deployment complete</zw-alert-title>
  <zw-alert-description>
    The new version is now available.
  </zw-alert-description>
</zw-alert>
tsx
import { Alert, AlertDescription, AlertTitle } from '@zeus-web/alert/react'

export function AlertExample() {
  return (
    <Alert variant="success">
      <AlertTitle>Deployment complete</AlertTitle>
      <AlertDescription>The new version is now available.</AlertDescription>
    </Alert>
  )
}
vue
<script setup lang="ts">
import { Alert, AlertDescription, AlertTitle } from '@zeus-web/alert/vue'
</script>

<template>
  <Alert variant="success">
    <AlertTitle>Deployment complete</AlertTitle>
    <AlertDescription>The new version is now available.</AlertDescription>
  </Alert>
</template>

添加 ​

bash
zweb add alert

导入 ​

样式化 Registry 组件:

tsx
import { Alert, AlertTitle, AlertDescription } from '@/components/ui/alert'

基础组件 React 包装器:

tsx
import { Alert, AlertTitle, AlertDescription } from '@zeus-web/alert/react'

Web Component 入口:

ts
import '@zeus-web/alert/wc/auto'

属性 ​

属性类型默认值说明
variantAlertVariant
可选值: default, info, success, warning, danger
default视觉样式变体。
livestringpoliteARIA 实时区域模式。

事件 ​

暂无公开事件。

插槽 ​

插槽说明
default警告提示内容。

样式 ​

使用 Tailwind: 是

主题变量:

  • bg-background
  • text-foreground
  • border

内部选择器:

  • [data-slot=alert-root]
  • [data-slot=alert-title]
  • [data-slot=alert-description]

Registry ​

Registry 源码:可用。

添加命令: zweb add alert

类型: component

依赖:

  • @zeus-web/alert
  • class-variance-authority

Registry 依赖:

  • cn
  • globals

文件:

  • templates/react/alert.tsx → components/ui/alert.tsx
  • templates/vue/alert.ts → components/ui/alert.ts

AI 使用规则 ​

建议:

  • 使用 Alert 展示系统消息。
  • 标题使用 AlertTitle。
  • 详细说明使用 AlertDescription。

避免:

  • 不要将 Alert 用作页面内容之外的持久横幅。

示例 ​

React 样式化用法 ​

tsx
import { Alert, AlertTitle, AlertDescription } from '@/components/ui/alert'

export function Example() {
  return (
    <Alert variant="info">
      <AlertTitle>Heads up!</AlertTitle>
      <AlertDescription>Info message here.</AlertDescription>
    </Alert>
  )
}

基于 MIT 许可证发布。