Badge
A small glass badge with its text flowing through the lens.
Latest changeImprovedv2.0.0The scrolling text stops while it is hidden behind the glass.
- v2.0.0ImprovedThe scrolling text stops while it is hidden behind the glass.
- v1.0.0NewFirst release, in
@vitrumui/react/badge. - All changes →
Autumn update
Sliders, switches and checkboxes, now in refractive 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
npm install @vitrumui/reactUsage
import { GlassBadge } from '@vitrumui/react/badge'
<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-*.
Examples
Notes
Radio
Studio
The badge takes its colour from its own classes: bg-* is the glass, text-* the text that flows through it, and dotColor the square between repeats. Hover speeds up only the badge whose positioned parent is under the pointer.
bg-emerald-600bg-rose-600bg-amber-400bg-sky-500bg-violet-600bg-neutral-900Any bg-* works as the glass. Pair it with a text-* that reads on it (dark text on amber, white on the rest) and a dotColor a shade away from the text. They sit side by side here only to compare: in a product, keep to one badge per view.
Night Drive LP
$26 $18
A rose badge hangs off the corner of the cover. Half of it is over the yellow and half over the page, so the glass shows both.
Put the badge inside the button and give the button relative: the orange badge then speeds up when that item is hovered, not the whole dock.
Colour Fields
Tonight, 21:00 · Hall B
Sold outtint is how much of the badge colour covers what is behind it. At the default 0.82 the badge reads as a solid colour; lower it over a colourful backdrop and the backdrop shows in the glass, softly blurred. speed is the pace at rest, in loops per second. The badge is 64 px wide by default: widen it with a w-* class for a longer word.
- StarterOne project, community support$0
- TeamPopularUnlimited projects, shared library$24
- ScaleAudit log, SSO and priority support$96
Without a position class the badge sits in the line like any inline element. Give the row relative so the hover that speeds the text up belongs to that row.
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.