Badge

Red dot, number or text. Used to tell users there are some updates.

Property

Description

Type

Default

Required

textNumber  or text to be displayed.String/Number

No

dotShow a  red dot instead of number.Boolean

No

overflowCountTop   number to be shown, “+” shown for more.Number99

No

Slots

slotNameDescription
inner Optional, when badge is wrapper, it is used to render the internal region.

Example

copy
{
  "defaultTitle": "AntUI Component Library",
  "usingComponents": {
    "list": "mini-antui/es/list/index",
    "list-item": "mini-antui/es/list/list-item/index",
    "badge": "mini-antui/es/badge/index"
  }
}
copy
<view>
  <list>
    <block a:for="{{items}}">
      <list-item
        arrow="{{true}}"
        index="{{index}}"
        key="items-{{index}}"
        last="{{index === (items.length - 1)}}"
      >
        <view>
          <badge a:if="{{item.isWrap}}" text="{{item.text}}" dot="{{item.dot}}">
            <view slot="inner" style="height: 26px; width: 26px; background-color: #ddd;"></view>
          </badge>
          <text style="margin-left: \{\{ item.isWrap ? '12px' : '0' \}\}">{{item.intro}}</text>
        </view>
        <view slot="extra">
          <badge a:if="{{item.isWrap}}" text="{{item.text}}" dot="{{item.dot}}" overflowCount="{{item.overflowCount}}" /> 
        </view>
      </list-item>
    </block>
  </list>
</view>
copy
Page({
  data: {
    items: [
      {
        dot: true,
        text: '',
        isWrap: true,
        intro: 'Dot Badge',
      },
      {
        dot: false,
        text: 1,
        isWrap: true,
        intro: 'Text Badge',
      },
      {
        dot: false,
        text: 99,
        isWrap: false,
        intro: 'Number Badge',
      },
      {
        dot: false,
        text: 100,
        overflowCount: 99,
        isWrap: false,
        intro: 'OverflowCount',
      },
      {
        dot: false,
        text: 'new',
        isWrap: false,
        intro: 'Text Badge',
      },
    ],
  },
});