Skip to content

Displays a compact inline status counter or label. It sits in the flow — for a bubble or dot anchored OVER another element, use BbIndicator (includes the co-located BbBadgeButton export).

import { BbBadge } from 'bitboss-ui';

On this page

Props

NameTypeDefaultDescription
append:iconstring | undefined-

Icon rendered after the label. On a clearable badge it shares the trailing slot with the clear button: the icon shows at rest and the clear button reveals over it on hover/focus.

See example
clearableboolean | undefinedfalse

Renders a trailing clear button and emits click:clear when pressed — turns the badge into a dismissible token (the pattern formerly served by BbChip).

Opt-in, which is the one thing that changed on the way from BbChip: a chip was removable unless told otherwise. Swapping the tag straight across loses the × with no error.

See example
clearableLabelstring | undefined-

Accessible label for the clear button. Rarely needed: unset, the name is **composed** from the localized badge.clearLabel verb and the badge's own text — "Remove Italy", not a bare "Remove" — which is already the right name in almost every case. Composition is skipped when a BbBadgeButton owns the body (the verb then stands alone, so the two controls do not both announce the label). Set this only to override that composed name outright.

See example
iconstring | undefined-

Renders an icon-only badge. When set, prepend:icon / append:icon are ignored and the default slot becomes the badge's visually hidden accessible label — always provide it.

See example
loadingboolean | undefinedfalse

Shows a spinner in place of the leftmost icon, mirroring BbButton: it replaces the icon glyph or the prepend:icon when one is set; when the append:icon is the sole icon it replaces that instead (e.g. a select-activator chevron while the value saves), and with no icons at all it takes the leading slot. Adds a visually hidden loading announcement for screen readers.

Also makes a slotted BbBadgeButton inert: clicks do not reach your @click, a link does not navigate, and the body leaves the tab order until loading clears.

See example
prepend:iconstring | undefined-

Icon rendered before the label.

See example
ptPtMap<BbBadgePtPart, "loading"> | undefined-

Passthrough, object form: { icon: '…', 'icon:loading': '…' } — the same keys as the pt:* attributes without the prefix. Parts: root, icon, spinner, text, clear. State: loading.

pt:clearPtValue | undefined-
pt:clear:loadingPtValue | undefined-
pt:iconPtValue | undefined-
pt:icon:loadingPtValue | undefined-
pt:rootPtValue | undefined-
pt:root:loadingPtValue | undefined-
pt:spinnerPtValue | undefined-
pt:spinner:loadingPtValue | undefined-
pt:textPtValue | undefined-
pt:text:loadingPtValue | undefined-
sizekeyof Sizes | undefined"md"

Preset size of the badge.

Pick it from the control standing next to the badge, not from a remembered constant: lg matches an xs button, xl a sm one, 2xl an md one. The default md is sized for running text.

See example
variantBadgeVariantType | undefined"primary"

Visual variant: primary, secondary, destructive, or outline. Register more via the vite plugin badgeVariants option and style .bb-badge--<variant> (set --bg / --fg). 'none' renders no variant class — an escape hatch for a one-off look set through --bg / --fg on the element.

See example

Events

NameTypeDescription
click:clear(event: "click:clear", event: MouseEvent): void

Fires when the clear button is pressed. The badge is controlled and removes nothing on its own — drop the item from your own state in the handler. Pressing the × never fires a slotted BbBadgeButton.

See example

Slots

The listed properties are the ones exposed to the slot scope.

NameTypeDescription
defaultobject

The badge's label content. When icon is set this becomes the visually hidden accessible label. Render a BbBadgeButton here to make the badge body interactive (the wrapper stays a passive <span>).

A BbBadgeButton here must be a direct child: wrapped in anything else the badge keeps its body and you get a duplicated label. One per badge — there is only one body to take over.

See example

Changes from v2

Props removed or renamed in 3.0. If you are coming from v2, the answer is here.

  • contentremovedfails silently