The New CSS

Badges

Pill-shaped badges and rectangular tags for status indicators, labels, and categorization. Part of the @thenewcss/badges addon package.

Installation

Install the badges addon via npm or load it from a CDN. Requires the core library.

npm install @thenewcss/badges

Color Variants

The base .badge class creates a pill-shaped label with blue styling. Add a color modifier to change the color scheme.

Preview

DefaultPrimaryDangerSuccessWarningDark
<span class="badge">Default</span> <span class="badge badge-primary">Primary</span> <span class="badge badge-danger">Danger</span> <span class="badge badge-success">Success</span> <span class="badge badge-warning">Warning</span> <span class="badge badge-dark">Dark</span>

Sizes

Badges come in three sizes. The default size works for most use cases. Use .badge-sm for compact layouts and .badge-lg for emphasis.

Preview

SmallDefaultLarge
<span class="badge badge-primary badge-sm">Small</span> <span class="badge badge-primary">Default</span> <span class="badge badge-primary badge-lg">Large</span>

Outline Badges

Use .badge-outline for a transparent background with a 1px solid border in the current text color.

Preview

DefaultPrimaryDangerSuccessWarning
<span class="badge badge-outline">Default</span> <span class="badge badge-primary badge-outline">Primary</span> <span class="badge badge-danger badge-outline">Danger</span> <span class="badge badge-success badge-outline">Success</span> <span class="badge badge-warning badge-outline">Warning</span>

Dot Badges

Add .badge-dot to prepend a small circle dot indicator via a ::before pseudo-element.

Preview

DefaultPrimaryDangerSuccessWarning
<span class="badge badge-dot">Default</span> <span class="badge badge-primary badge-dot">Primary</span> <span class="badge badge-danger badge-dot">Danger</span> <span class="badge badge-success badge-dot">Success</span> <span class="badge badge-warning badge-dot">Warning</span>

Tags

Tags are rectangular labels for categorization. Use .tag for individual tags and .tag-list for a flex container that wraps tags with consistent spacing.

Preview

HTMLCSSJavaScriptTypeScriptReact
<div class="tag-list"> <span class="tag">HTML</span> <span class="tag">CSS</span> <span class="tag">JavaScript</span> <span class="tag">TypeScript</span> <span class="tag">React</span> </div>

Class Reference

Base

ClassDescription
.badgePill-shaped inline-flex label. Padding 0.125rem/0.5rem, font-size 0.75rem, font-weight 500, full border-radius, blue-50 background, blue-600 text, nowrap.

Colors

ClassDescription
.badge-primaryBlue background and text color.
.badge-dangerRed background and text color.
.badge-successGreen background and text color.
.badge-warningYellow background and text color.
.badge-darkGray-900 background with white text.

Sizes

ClassDescription
.badge-smSmall badge. Padding 0/0.25rem, font-size 0.625rem.
.badge-lgLarge badge. Padding 0.25rem/0.75rem, font-size 0.875rem.

Styles

ClassDescription
.badge-outlineTransparent background with a 1px solid currentColor border.
.badge-dotPrepends a 0.375rem circle dot indicator via ::before pseudo-element.

Tags

ClassDescription
.tagInline-flex rectangular label. Padding 0.25rem/0.75rem, font-size 0.875rem, medium border-radius, gray-100 background, gray-800 text.
.tag-listFlex container with wrap and 0.5rem gap for grouping tags.