Skip to content

Components

Badge

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

Latest change Fixed v2.0.2 Once its glass has drawn, a Badge hides its plain CSS look, but the marquee in that look kept running unseen. It ran on the main thread, so on every frame of anything else on the page the browser worked out all of the page's layers again: several milliseconds a frame, on every page with a Badge. The hidden marquee now stops; without WebGL2 it runs as before.
  1. v2.0.2 Fixed Once its glass has drawn, a Badge hides its plain CSS look, but the marquee in that look kept running unseen. It ran on the main thread, so on every frame of anything else on the page the browser worked out all of the page's layers again: several milliseconds a frame, on every page with a Badge. The hidden marquee now stops; without WebGL2 it runs as before.
  2. v1.5.8 Improved A 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.
  3. v1.3.10 Fixed A 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.
  4. v1.3.7 Improved Three more examples: a palette of six colours, a rose sale badge on a product and an orange badge on a dock item.
  5. v1.3.3 Improved Three examples: your own colours, clearer glass over a colourful backdrop (tint, speed, a wider badge), and a badge inline next to a label.
  6. v1.0.0 New A badge whose text flows through the glass.
  7. All changes→
glass-badge-basic.svelte

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-svelte@latest add https://liquidglass.pulse.city/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.

Liquid Glass Svelte is open source and MIT licensed. If it saves you time, you can support the project.