Skip to main content

Components

Badge

Badge is a non-interactive component that displays status with or without a number. Use Tag if you want text instead of a number.

count
Description

The number to display in the badge

Type
number
maxCount
Description

The maximum number to display in the badge, when the count exceeds this number, the badge will display `{max}+`

Type
number
variant
Description

Change the background color of the badge.

Type
"base" | "tinted"
Default
base
NameTypeDefaultDescription
countnumber-

The number to display in the badge

maxCountnumber-

The maximum number to display in the badge, when the count exceeds this number, the badge will display `{max}+`

variant"base" | "tinted"base

Change the background color of the badge.

BadgePosition

placement
Description

The placement of the badge

Type
"top-right" | "top-left" | "bottom-right" | "bottom-left"
Default
top-right
overlap
Description

Use when badge is floating to change the position of the badge

Type
"circle" | "rectangle"
Default
rectangle
NameTypeDefaultDescription
placement"top-right" | "top-left" | "bottom-right" | "bottom-left"top-right

The placement of the badge

overlap"circle" | "rectangle"rectangle

Use when badge is floating to change the position of the badge

Examples

Variants

You can switch between variant and data-color to get different colors and styles.

Floating

You can set the placement with placement, and choose what type of overlap it can have.

Not all icons have the same shape, and then you may have to change where the Badge should be placed. If you can't get the Badge to be where you want it, you can use style to override the placement. This also works when using overlap="circle".

Inline

To have the Badge inline, place it directly in the text or component.

HTML

Badge renders its text with CSS in a :before pseudo-element on a span tag. You use the class name ds-badge, in conjunction with the data attribute.

If you want it to be floating, ds-badge--position must be used on a wrapper around the element that the Badge is to be placed over. data-placement is used on the wrapper to determine the placement. See the bottom of the page for supported placements. You can also set data-overlap="circle" on it to get circular overlap.

CSS variables and data attributes

Edit this page on github.com (opens in a new tab)