Skip to Content

Badge

Display badge, pill or tag.

Import

import { Badge } from '@tidbcloud/uikit'

Usage

import { Badge } from '@tidbcloud/uikit' function Demo() { return <Badge>Badge</Badge> }

Variants

Badge supports several variants: filled, light, outline, dot, transparent, white, and default.

import { Badge, Group } from '@tidbcloud/uikit' function Demo() { return ( <Group> <Badge variant="filled">Filled</Badge> <Badge variant="light">Light</Badge> <Badge variant="outline">Outline</Badge> <Badge variant="dot">Dot</Badge> </Group> ) }

Gradient

import { Badge } from '@tidbcloud/uikit' function Demo() { return ( <Badge size="xl" variant="gradient" gradient={{ from: 'cyan', to: 'blue', deg: 90 }}> Gradient badge </Badge> ) }

Rounded

Set circle prop to make badge width equal to its height:

import { Badge, Group } from '@tidbcloud/uikit' function Demo() { return ( <Group> <Badge size="xs" circle> 1 </Badge> <Badge size="sm" circle> 7 </Badge> <Badge size="md" circle> 9 </Badge> <Badge size="lg" circle> 3 </Badge> </Group> ) }

Left and right sections

import { Badge, Group } from '@tidbcloud/uikit' import { IconAt } from '@tabler/icons-react' function Demo() { const icon = <IconAt size={12} /> return ( <Group> <Badge leftSection={icon}>With left section</Badge> <Badge rightSection={icon}>With right section</Badge> </Group> ) }

Full width

Set fullWidth to make badge span full width of its parent:

import { Badge } from '@tidbcloud/uikit' function Demo() { return <Badge fullWidth>Full width badge</Badge> }

Props

PropTypeDefaultDescription
childrenReact.ReactNode-Main badge content
circleboolean-If set, badge min-width becomes equal to its height
colorMantineColor-Key of theme.colors or any valid CSS color
fullWidthboolean-If set, badge takes 100% width of its parent
gradientMantineGradient-Gradient configuration for variant="gradient"
leftSectionReact.ReactNode-Content displayed on the left side
radiusMantineRadius-Border radius
rightSectionReact.ReactNode-Content displayed on the right side
sizeMantineSize'md'Controls font-size, height and padding
variantstring'filled'Visual variant
Last updated on