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

Badge

Badge 表示状态或类别的短文本。

StorybookSourceRecipe Source

Usage

Badge

Disabled

Badge

Sizes

Extra SmallSmallMediumLarge

Radii

Extra SmallSmallMediumLargeFullNone

Colors

BlueCyanGrayOrangeRedGreenPinkPurpleYellow

Variants

SolidOutlinedFadedSubtle

With Close Button

添加 closable 属性,可以在 Badge 上显示一个关闭按钮。 onClose 回调函数会在关闭按钮被点击时触发。

Badge

With Icons

GithubGithub

List of Badges

AppleBananaCherryWatermelonOrange

API

Badge Props

Badge 继承 as (默认为 'span') 的 Props。

PropTypeDefaultDescription
childrenReactNode-Badge 的内容。
color'blue'|'orange'|'yellow'|'cyan'|'red'|'green'|'pink'|'purple'|'gray''blue'Badge 的颜色。
variant'solid'|'outlined'|'subtle'|'faded''solid'Badge 的外观样式。
size'xs'|'sm'|'md'|'lg''md'Badge 的大小。
radius'xs'|'sm'|'md'|'lg'|'full'|'none'sizeBadge 的 BorderRadius。
disabledbooleanfalseBadge 是否禁用。
closablebooleanfalse是否显示关闭按钮。
onClose(event: React.MouseEvent<HTMLButtonElement>) => void-关闭按钮被点击时触发的回调函数。
startIconReactNode-放置在子元素之前的元素。
endIconReactNode-放置在子元素之后的元素。
classNameClassValue-用于根元素的 className。
refRef-用于转发根元素。
asElementType'span'用于根元素的组件。可以是表示 HTML 元素的字符串,也可以是一个组件。
sxInterpolation-用于根元素的 sx 属性。
classNamesPartial<Record<Slots, ClassValue>>-Badge Slots 的 className。
slotPropsPartial<Record<Slots, ComponentProps>>-Badge Slots 的 props。

Badge Slots

Slot NameClass NameDefault ComponentDescription
closeButton.nui-badge-close-button'span'Badge 的关闭按钮。
startIcon.nui-badge-start-icon'span'Badge 内开头图标的容器。
endIcon.nui-badge-end-icon'span'Badge 内结尾图标的容器。
最后更新时间