Skip to content

Components

Badge

A small glass badge with its text flowing through the lens.

Latest changeImprovedv1.5.8A clear badge (tint at 0.6 or below) now mirrors its surroundings on its rim, as clear buttons do; a badge in its own colour looks the same as before. The first example is now a plain outlined card with one orange badge on its corner.
  1. v1.5.8ImprovedA clear badge (tint at 0.6 or below) now mirrors its surroundings on its rim, as clear buttons do; a badge in its own colour looks the same as before. The first example is now a plain outlined card with one orange badge on its corner.
  2. v1.3.10FixedA text-* class on the badge now always wins over its built-in white. Dark text on a light badge stayed white before: the Live badge in the examples was white on white.
  3. v1.3.7ImprovedThree more examples: a palette of six colours, a rose sale badge on a product and an orange badge on a dock item.
  4. v1.3.3ImprovedThree examples: your own colours, clearer glass over a colourful backdrop (tint, speed, a wider badge), and a badge inline next to a label.
  5. v1.0.0NewA badge whose text flows through the glass.
  6. All changes →
glass-badge-basic.tsx

Kasım

Sliders, switches and checkboxes, now in liquid glass.

New

Use it for

  • One short word on a card or a tab: New, Beta, Live.

Not for

  • Counts or status that must be read at a glance: the text is moving.
  • Several on one screen: the motion competes.

Installation

npx shadcn@latest add https://onemorethink.dev/r/badge.json

Usage

app.tsx
import { GlassBadge } from '@/components/liquid-glass'

<div className="relative">
  <Card />
  <GlassBadge className="absolute -top-2 -right-2">New</GlassBadge>
</div>

Behaviour

The text is drawn beneath the glass, so the rim bends the letters as they pass. Whatever sits behind the badge shows through, softly blurred. Hovering the badge's positioned parent speeds the flow up. Colour it with bg-* and text-*. With tint at 0.6 or below the glass counts as clear, and its rim mirrors the colours around it.

API reference

PropTypeDefault
children

The text: one short word.

string—
dotColor

Separator colour between repeats.

stringcurrentColor
speed

Loops per second at rest.

number0.4
tint

Opacity of the badge colour over the backdrop.

number0.82
className

Position and colour (bg-*, text-*).

string—

Accessibility

  • The text is announced once, not as a loop.
  • With reduced motion the text stands still, centred.