Right now there is no stable version available for this library. We're just working on it. 🚀

Alert

Alert 是一种临时通知,提供有关操作或事件的简明反馈。

StorybookWAI-ARIASourceRecipe Source

Anatomy

import { Alert } from '@nex-ui/react'

Usage

Colors

Variants

Radii

Status

使用 status 属性可以设置 Alert 的状态,每个状态都具有不同的颜色以及图标。

Alert 支持 error、success、warning 和 info 四种状态,默认为 info。

Note: color 属性可覆盖状态的默认颜色。

Custom Icon

默认,Alert 会根据 status 属性显示相应的图标。您也可以通过 icon 属性传入自定义图标。

Without Icon

将 hideIcon 属性设置为 true,可以隐藏图标。

With Action

使用 action 属性执行额外的操作。

Closable

将 closable 属性设置为 true,将会显示一个关闭按钮,onClose 在按钮被点击时触发。

API

Alert Props

Alert 继承 as (默认为 'div') 的 Props。

PropTypeDefaultDescription
classNameClassValue-用于根元素的 className。
refRef-用于转发根元素。
asElementType'div'用于根元素的组件。可以是表示 HTML 元素的字符串,也可以是一个组件。
sxInterpolation-用于根元素的 sx 属性。
classNamesPartial<Record<Slots, ClassValue>>-Alert Slots 的 className。
slotPropsPartial<Record<Slots, ComponentProps>>-Alert Slots 的 props。
color'blue'|'orange'|'yellow'|'cyan'|'red'|'green'|'pink'|'purple'|'gray'-Alert 的颜色。
radius'sm'|'md'|'lg'|'full'|'none''md'Alert 的 borderRadius。
variant'outlined'|'faded'|'solid'|'subtle''faded'Alert 的外观样式。
iconReactNode-自定义图标。
actionReactNode-在信息的后面显示的操作。
titleReactNode-Alert 的标题。
descriptionReactNode-Alert 的描述。
closableboolean-Alert 是否可关闭。
status'error'|'info'|'success'|'warning''info'Alert 的状态。
hideIconboolean-是否隐藏 icon。
onClose() => void-当关闭按钮被点击时触发。

Alert Slots

Slot NameClass NameDefault ComponentDescription
icon.nui-alert-icon'div'Alert 的图标容器。
content.nui-alert-content'div'Alert 的内容容器。
title.nui-alert-title'div'Alert 的标题容器。
description.nui-alert-description'div'Alert 的描述容器。
closeButton.nui-alert-close-buttonButtonAlert 的关闭按钮。
最后更新时间