Skip to content

Components

Badge

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

Markdown
Latest changeImprovedv2.0.0The scrolling text stops while it is hidden behind the glass.
  1. v2.0.0ImprovedThe scrolling text stops while it is hidden behind the glass.
  2. v1.0.0NewFirst release, in @vitrumui/react/badge.
  3. All changes →
glass-badge-basic.tsx

Autumn update

Sliders, switches and checkboxes, now in refractive 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

npm install @vitrumui/react
Peer: React 19

Usage

app.tsx
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

Your colours
glass-badge-colors.tsx
Beta

Notes

Live

Radio

Pro

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.

A palette
glass-badge-palette.tsx
Openbg-emerald-600
Salebg-rose-600
Soonbg-amber-400
Betabg-sky-500
Probg-violet-600
Newbg-neutral-900

Any 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.

On a product, for a sale
glass-badge-product.tsx

Night Drive LP

$26 $18

Sale

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.

On a dock item
glass-badge-dock.tsx

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.

Clearer glass over colour
glass-badge-tint.tsx

Colour Fields

Tonight, 21:00 · Hall B

Sold out

tint 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.

Inline, next to a label
glass-badge-inline.tsx
  • 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

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.