How to Build Status Badges, Notification Dots & Pill Tags in Pure CSS

The Quick Answer

To build an animated status dot in pure CSS, position a span inside a relative container, set border-radius: 50%, and attach an absolute pseudo-element (::before) with animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite that expands with transform: scale(2.5) and fades to opacity: 0. For corner badges, anchor them with top: 0; right: 0; transform: translate(50%, -50%).

Interactive Demo Live Preview
JD
Inbox 12
PRO FEATURE

Step 1: Absolute Positioning for Corner Badges (The 50% Translate Trick)

Placing a count badge on the corner of an avatar or button is notoriously error-prone with static margins. The robust formula sets position: absolute; top: 0; right: 0; transform: translate(50%, -50%);. This centers the badge precisely over the container's top-right apex regardless of badge width.

corner-badge.css
.avatar-wrapper {
  position: relative;
  display: inline-block;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--background);
}

Step 2: The Radar Ping Pulse Keyframe Animation

Live audio feeds, active chat users, and online system monitors rely on a glowing pulse animation. By placing an absolute pseudo-element directly beneath the colored dot and animating its scale and opacity simultaneously, you achieve a continuous radar ripple.

pulse-dot.css
.status-dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
}

.status-dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: radarPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(3); opacity: 0; }
}

Step 3: WCAG-Compliant Contrast with OKLCH Color Mixing

Light-tinted badges with dark text often fail accessibility tests when hardcoded with alpha channels. Using color-mix(in oklch, ...) produces translucent background tints that retain high chroma while keeping text readable.

badge-contrast.css
.badge-success {
  background: color-mix(in oklch, #10b981 15%, transparent);
  border: 1px solid color-mix(in oklch, #10b981 35%, transparent);
  color: #34d399;
}

.badge-warning {
  background: color-mix(in oklch, #f59e0b 15%, transparent);
  border: 1px solid color-mix(in oklch, #f59e0b 35%, transparent);
  color: #fbbf24;
}

Step 4: Removable Filter Chips using Modern :has()

Filter chips often feature an 'x' dismiss icon. With modern CSS :has(), you can style the entire chip when its delete button is hovered or active without a single line of JavaScript.

chip-tag.css
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.chip:has(.delete-btn:hover) {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

Icon
→ anchored badge →
99+

1. CSS Anchor Positioning for Notification Badges

Explore in Anchor Positioning Studio →

Tether floating counter badges to any UI icon or avatar using native CSS position-anchor without requiring relative parent containers.

4px Squircle 9999px Pill

2. Curvature Token Hierarchy (Pill, Squircle, Round)

Explore in Radius Tokens Studio →

Harmonize corner rounding tokens across your design system from tight 4px squircle badges to full 9999px pill contours.

ONLINE RADAR ACTIVE

3. Ambient Glowing Drop Shadows for Dark Mode Badges

Explore in Box Shadow Studio →

Project neon penumbra halos around active status badges to make them pop against dark dashboard surfaces.

Chaam
Chaam's Pro Tip

A trick I use in almost every project: don't fight specificity battles with !important. Leverage modern CSS cascade layers (@layer) and CSS variables as design tokens—it makes dark/light theme switching and responsive tuning effortless.

Why I Built the Badges & Tags Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in Badges & Tags Studio ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

How do you position a notification badge in the top-right corner of an icon or avatar?

Set the parent container to 'position: relative;' and the badge to 'position: absolute; top: 0; right: 0; transform: translate(50%, -50%);'. This ensures the badge center point sits exactly on the parent corner regardless of padding.

How do you create an infinite pulsing radar ping dot in pure CSS?

Add an absolute ::before pseudo-element with the same background color. Animate it with '@keyframes ping { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(3); opacity: 0; } }' with animation-timing-function: cubic-bezier(0, 0, 0.2, 1).

How do you ensure status badge colors meet WCAG AA contrast standards?

Avoid low-contrast white text on bright yellow or light green badges. Instead, use dark text (e.g. #0f172a) on pastel badges, or use semi-transparent tinted backgrounds with high-chroma text (e.g. #34d399 text on rgba(52,211,153,0.15) background).

Can CSS Anchor Positioning replace absolute positioning for notification badges?

Yes! In Chrome 125+, declare 'anchor-name: --avatar' on the photo and 'position-anchor: --avatar; top: anchor(top); right: anchor(right);' on the badge. This eliminates the need for parent wrapper divs with position: relative.

How do you truncate long text inside pill tags with an ellipsis?

Declare 'max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;' on the badge container while keeping display: inline-flex or inline-block.

← Back to all blog guides Launch Generator Studio →