Skip to content

The library's inline pill: status labels, counts and removable tokens.

import { BbBadge } from 'bitboss-ui';

On this page

Use it for

BbBadge is a small inline pill: a status label (Active, Beta), a short count, a token the user can dismiss.

Use something else when

  • BbIndicator, when the marker belongs on top of something else: an unread count on a bell, a presence dot on an avatar
  • BbTag, when the token is an input people type free-form values into
  • BbButton, when it is a standalone action

Pass Through

Hover or tap a part to outline it. Toggles flip loading, errors and warnings when the component has them — only parts highlight.

Heads up
Coming from v2

Two v2 names land here. The v2 BbBadge, the count anchored to an element, is now BbIndicator: rename the tag and move content to text. BbChip is this badge with clearable, which you now have to write yourself.

Status labels

Write the label inside the badge; there is no text or content prop.

NewDraftv2.4.0Overdue
Paid Continue Verified
In textBeside a small control

A badge is inert until you add clearable or a BbBadgeButton.

Variants

variant picks the tone of the pill: primary, secondary, outline, destructive. primary is the default.

Keep destructive for what is actually wrong. There is no success variant, and an unregistered name colors nothing, so register the tones you need. variant="none" drops the variant class entirely, for pills you color yourself.

Sizes

Sizes run from xs to 2xl, md is the default and the one meant for a line of running text.

Beside a control the badge runs larger than the button it pairs with: lg next to xs, xl next to sm, 2xl next to md.

Icons

prepend:icon and append:icon put an icon beside the label. With icon the badge goes icon-only and the slot becomes its accessible name, so keep writing the label.

Removable tokens

clearable adds a trailing clear button and emits click:clear when it is pressed.

Filtered byFurnitureDisplaysAudio & Video

The badge does not remove itself: taking the item out of your own state is your job.

Clickable badges

To make the pill's body clickable, slot a BbBadgeButton as a direct child of the default slot. The clear button stays beside it, with its own tab stop.

Press the label to change the value, the × to drop the filter. They are two tab stops.

BbBadgeButton composes BbBaseButton, so it also takes href, to, target, rel and disabled.

Both constraints are silent. Wrap the companion in another element and you are left with a duplicated label, and a plain <button> of your own nests inside another button as soon as the badge is clearable.

Loading

loading swaps a spinner in for the leftmost icon: the trailing one when that is the only icon, a leading slot of its own when there are none.

Status: Open Payment Syncing

A loading badge ignores clicks on its BbBadgeButton: your @click does not fire, a link does not navigate and the body leaves the tab order. Set loading while the action saves and a second press cannot run it twice.

Custom tones

For a tone that recurs across the product, register a variant in the plugin config instead of coloring pills one at a time.

ts
// nuxt.config.ts
export default defineNuxtConfig({
    bitboss: { badgeVariants: ['soft-green'] },
});

The registered name joins the TypeScript union behind variant and gives you a .bb-badge--soft-green hook. You write the CSS, setting the two custom properties the built-in variants drive.

css
.bb-badge.bb-badge--soft-green {
    --bg: color-mix(in oklab, #16a34a 15%, var(--bb-panel));
    --fg: color-mix(in oklab, #16a34a 80%, var(--bb-text));
}

For a one-off accent, override the same properties inline, :style="{ '--bg': '#7c3aed' }", and check the contrast yourself.

When the colors come from data, such as labels each workspace colors its own way, there is no name to register. Set variant="none": the badge renders no variant class and you paint it with --bg and --fg. Until you set them it keeps the base primary colors.

BackendNeeds designGood first issueBlocked
Coming from v2v2 stylesheets

.bb-badge, .bb-badge__content, .bb-badge__clear-button and the variant and size modifiers all still match. Only direct-child selectors broke: the pill now holds two sides, .bb-badge__body and .bb-badge__trailing, so .bb-badge > .bb-badge__content has to become a descendant selector.