Skip to content

Badge ​

A small label used to indicate status, category, or metadata on an element.

Basic Usage ​

Badge
<bo-badge label="Badge" />

Or with a slot:

apple
<bo-badge>apple</bo-badge>

Kinds ​

Badges come in two kinds. The default kind is default.

  • default: filled with a background color
  • outline: transparent background with a border
DefaultOutline
<bo-badge label="Default" kind="default" />
<bo-badge label="Outline" kind="outline" />

Variants ​

Filled ​

PrimarySecondarySuccessWarningDestructiveLightBlack
<bo-badge label="Primary" variant="primary" />
<bo-badge label="Secondary" variant="secondary" />
<bo-badge label="Success" variant="success" />
<bo-badge label="Warning" variant="warning" />
<bo-badge label="Destructive" variant="destructive" />
<bo-badge label="Light" variant="light" />
<bo-badge label="Black" variant="black" />

Outline ​

PrimarySecondarySuccessWarningDestructiveLightBlack
<bo-badge label="Primary" kind="outline" variant="primary" />
<bo-badge label="Secondary" kind="outline" variant="secondary" />
<bo-badge label="Success" kind="outline" variant="success" />
<bo-badge label="Warning" kind="outline" variant="warning" />
<bo-badge label="Destructive" kind="outline" variant="destructive" />
<bo-badge label="Light" kind="outline" variant="light" />
<bo-badge label="Black" kind="outline" variant="black" />

Shapes ​

Available shapes: default, pill, flat, circle.

WARNING

To render a circle badge, set shape="circle" and provide a prefixIcon or suffixIcon.

DefaultPillFlat
<bo-badge label="Default" shape="default" />
<bo-badge label="Pill" shape="pill" />
<bo-badge label="Flat" shape="flat" />
<bo-badge prefix-icon="x_octagon" shape="circle" />
<bo-badge prefix-icon="x_octagon" shape="circle" kind="outline" />

Icons ​

Use prefixIcon and suffixIcon to display icons before or after the label.

Prefix IconSuffix Icon
<bo-badge label="Prefix Icon" prefix-icon="x_octagon" />
<bo-badge label="Suffix Icon" suffix-icon="x_octagon" />

Custom Colors ​

Use customColor and customTextColor to set arbitrary colors. Accepts hex, RGB/RGBA, OKLCH, or CSS variables.

CBCBCBCB
<bo-badge label="CB" custom-color="#880808" />
<bo-badge label="CB" custom-color="rgb(34, 197, 94)" custom-text-color="#FFFFFF" />
<bo-badge label="CB" custom-color="oklch(84.5% 0.143 164.978)" custom-text-color="#000000" />
<bo-badge label="CB" kind="outline" custom-color="oklch(84.5% 0.143 164.978)" />

Cursor ​

cursor-autocursor-pointercursor-not-allowed
<bo-badge label="cursor-auto" cursor="cursor-auto" />
<bo-badge label="cursor-pointer" cursor="cursor-pointer" />
<bo-badge label="cursor-not-allowed" cursor="cursor-not-allowed" />

API Reference ​

Props ​

PropTypeDefaultDescription
idstringAutogeneratedThe id of the element.
dataTestIdstringAutogeneratedThe data test id of the element.
labelstring-The label text to display on the badge.
kindBoBadgeKinddefaultThe type of the badge (filled or outline).
shapeBoBadgeShapedefaultThe shape of the badge.
variantBoBadgeVariantprimaryThe color variant of the badge.
cursorBoCursorcursor-autoThe cursor style of the badge.
customColorstring-The custom background color for the badge.
customTextColorstring-The custom text color for the badge.
prefixIconIcon-The prefix icon of the badge.
suffixIconIcon-The suffix icon of the badge.
roleHTMLAttributes['role']-The role of the element.
ariaLabelHTMLAttributes['aria-label']-Defines a string value that labels the current element.

Slots ​

NamePropsDescription
default-The default slot for badge content

TIP

Using the default slot replaces the label. The prefixIcon and suffixIcon props still apply.

Released under the MIT License.