Badge

The Badge component is used to highlight and display short status descriptors, notifications, or labels. It supports various variants, sizes, and shapes, and can include icons or counters.

Import

import { Badge } from 'rebel-ui';

Usage

Basic Badge

New
<Badge label="New" />

Badge Variants

Available variants: default, primary, and error.

Default Primary Error
<Badge label="Default" variant="default" />
<Badge label="Primary" variant="primary" />
<Badge label="Error" variant="error" />

Badge Sizes

Available sizes: sm, md, and lg.

Small Medium Large
<Badge label="Small" size="sm" />
<Badge label="Medium" size="md" />
<Badge label="Large" size="lg" />

Badge Shapes

Available shapes: rounded, pill, and square.

Rounded Pill Square
<Badge label="Rounded" shape="rounded" />
<Badge label="Pill" shape="pill" />
<Badge label="Square" shape="square" />

Badge with Icon

With Icon
<Badge 
    label="With Icon" 
    icon={() => `<svg>...</svg>`} 
/>

Badge with Counter

5 99 99+
<Badge counter={5} />
<Badge counter={99} />
<Badge counter={100} /> <!-- Shows as "99+" -->

Badge with Dot

Notifications
<Badge label="Notifications" showDot />

Disabled Badge

Disabled
<Badge label="Disabled" disabled />

Bordered Badge

Bordered
<Badge label="Bordered" bordered />

Custom Colored Badge

Custom
<Badge label="Custom" customColor="#8B5CF6" />

Props

PropTypeDefaultDescription
labelstring''The text content of the badge
variant'default' \| 'primary' \| 'error''default'The visual style variant of the badge
size'sm' \| 'md' \| 'lg''md'The size of the badge
shape'rounded' \| 'pill' \| 'square''pill'The shape of the badge
icon() => stringundefinedFunction that returns an SVG string for the icon
showDotbooleanfalseWhether to show a dot indicator
counternumberundefinedDisplays a number (shows “99+” for numbers > 99)
disabledbooleanfalseWhether the badge is disabled
borderedbooleanfalseWhether to show a border
customColorstringundefinedCustom color for the badge (CSS color value)

Sizes

SizePaddingFont Size
sm0.125rem 0.375rem0.75rem
md0.25rem 0.5rem0.875rem
lg0.375rem 0.75rem1rem

Styling

The Badge component uses CSS variables for theming:

.badge {
    --rebel-surface: /* background color for default variant */
    --rebel-text-primary: /* text color */
    --rebel-brand: /* background color for primary variant */
    --rebel-error: /* background color for error variant */
    --rebel-border: /* border color when bordered is true */
}

Accessibility

  • Uses semantic HTML with appropriate ARIA attributes
  • Includes role="status" for screen reader announcements
  • Provides aria-label for badge content
  • Icons are properly hidden from screen readers with aria-hidden="true"
  • Maintains color contrast ratios for all variants
  • Disabled state is properly conveyed to assistive technologies

Examples

Notification Badge

3

Status Badge

Online

Error Badge

Failed