Badge

A short label that marks an item, such as a status, a count, or a category.

DefaultSuccessRemovedNew

Usage

Code
import { Badge } from '@leverui/components';
Code
<Badge>Badge</Badge>

Examples

Icon

Render an icon within the badge directly

NewNew

Variants

Badges come in different variants

OutlineSolidSubtleSurface

Sizes

Badges come in different sizes

NewNewNewNew

Props

PropDefaultTypeDescription
colorPalettegraystringColor palette, built-in or your own.
variantsubtle'solid' | 'subtle' | 'outline' | 'surface' | 'plain'Badge style.
sizesm'xs' | 'sm' | 'md' | 'lg' or responsive mapBadge size.
asspanNative HTML tagHTML tag to render.
asChild—Solid render functionRender your own element with the badge's props.
unstyledfalsebooleanTurn off the Lever UI styles.

Takes native HTML attributes, including class and style. BadgePropsProvider sets default props and HTML attributes for the badges inside it. A provider class and a badge class both apply. A prop on a badge wins.

Do not use color alone to show status. The text must make sense without it. If screen readers must announce a status change, put the badge in a live region.

Customize with CSS

.leverui-badge takes its colors from the palette variables. Set them on your own class to change one badge.

Code
<Badge class="status-badge" variant="solid" colorPalette="blue">
  In review
</Badge>
Code
.status-badge {
  --leverui-colors-color-palette-solid: #24406d;
  --leverui-colors-color-palette-contrast: white;
}

Set the same variables on a parent to change many badges. Each badge has data-size and data-variant attributes for CSS selectors. With a responsive size, it uses data-size-sm through data-size-2xl at the matching breakpoints.