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.
- v1.5.8ImprovedA clear badge (
tintat 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. - 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. - 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.
- 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. - v1.0.0NewA badge whose text flows through the glass.
- All changes →
glass-badge-basic.tsx
Kasım
Sliders, switches and checkboxes, now in liquid glass.
NewUse 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.jsonNo dependenciesOr copy the files by hand →
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
| Prop | Type | Default |
|---|---|---|
childrenThe text: one short word. | string | — |
dotColorSeparator colour between repeats. | string | currentColor |
speedLoops per second at rest. | number | 0.4 |
tintOpacity of the badge colour over the backdrop. | number | 0.82 |
classNamePosition and colour ( | string | — |
Accessibility
- The text is announced once, not as a loop.
- With reduced motion the text stands still, centred.