Indicator

Display an indicator element at the corner of another element, commonly used for badges, notifications, or status indicators.

Import

import { Indicator } from '@tidbcloud/uikit'

Basic Usage

import { Indicator, Avatar } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Indicator>
      <Avatar size="lg" radius="sm" src="https://example.com/avatar.png" />
    </Indicator>
  )
}

With Label

Display content inside the indicator:

import { Indicator, Avatar } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Indicator inline label="New" size={16}>
      <Avatar size="lg" radius="sm" src="https://example.com/avatar.png" />
    </Indicator>
  )
}

Offset

Adjust position for elements with border-radius:

import { Indicator, Avatar } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Indicator inline size={16} offset={7} position="bottom-end" color="red" withBorder>
      <Avatar size="lg" radius="xl" src="https://example.com/avatar.png" />
    </Indicator>
  )
}

Processing Animation

Add a pulsing animation to the indicator:

import { Indicator, Avatar } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Indicator inline processing color="red" size={12}>
      <Avatar size="lg" radius="sm" src="https://example.com/avatar.png" />
    </Indicator>
  )
}

Disabled

Hide the indicator by setting disabled:

import { Indicator, Avatar } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Indicator inline disabled color="red" size={12}>
      <Avatar size="lg" radius="sm" src="https://example.com/avatar.png" />
    </Indicator>
  )
}

Key Props

PropTypeDescription
labelReactNodeLabel displayed inside the indicator
colorMantineColorIndicator background color
sizenumber | stringIndicator width and height
position'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'Position relative to target
offsetnumberOffset from target element
processingbooleanEnable pulsing animation
disabledbooleanHide the indicator
withBorderbooleanAdd border to indicator
inlinebooleanMake container inline-block