Skip to content

Alert 警告提示

用于显示需要用户注意的信息。基于 BrConfigProvider 实现全局主题配置。

基础用法

Example

变体

使用 variant 属性控制警告提示的视觉风格。

  • Default: 默认风格。
  • Primary: 主色风格。
  • Success: 成功色风格。
  • Destructive: 破坏性(错误)色风格。
  • Warning: 警告色风格。
  • Info: 信息色风格。
Example

自定义内容 (可关闭)

通过组合式 API,你可以轻松添加自定义内容,例如关闭按钮。

Example

自定义内容 (可折叠)

你可以利用 Vue 的标准特性构建复杂的交互,如可折叠的警告提示。

Example

带图标

将图标作为 Alert 组件的第一个子元素即可。

Example

主题定制

全局定制 (BrConfigProvider)

你可以通过 BrConfigProvidertheme 属性覆盖默认 CSS 变量。

Example

局部定制 (TailwindCSS)

你可以直接使用 TailwindCSS 工具类覆盖样式。

vue
<template>
  <BrAlert class="bg-indigo-500 hover:bg-indigo-600">
    <BrAlertTitle>Custom Class</BrAlertTitle>
    <BrAlertDescription>Custom styled alert.</BrAlertDescription>
  </BrAlert>
</template>

API

组件

  • BrAlert: 主容器。
  • BrAlertTitle: 标题组件。
  • BrAlertDescription: 描述组件。

BrAlert Props

属性名类型默认值说明
variantstring'default'视觉风格变体: default, primary, success, destructive, warning, info
classstringundefined自定义类名