Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Mercury Background for React

Liquid chrome: a polished metal sheet whose soft swells roll slowly, each catching bright bands of light, while a streak of light sweeps across. For React with Base UI, when a product or launch page wants a chrome, futuristic surface behind its copy.

Framework

Liquid chrome fills the box: a polished metal sheet whose soft swells roll slowly, each with a bright band of light on its shoulder and a white highlight on its crest, while a broad streak of light sweeps across now and then. On a light page it's bright silver; on a dark one, graphite with cool highlights. Each of the two sheets is an SVG height field of smooth noise run through a chrome curve, the way polished metal reflects a sky and a horizon, then coloured in your theme; the browser draws it once, and CSS keyframes drift the two sheets in opposite directions, the second laid over the first, so their reflections meet and part. Only transforms animate, and no script runs.

Use it behind a product or launch page that wants a chrome, futuristic surface. For an iridescent foil, use Hologram; for a flowing satin sheen, Silk; for viscous blobs that merge and split, Metaballs; for veined stone made the same way, Marble.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { Mercury } from "@/components/ui/mercury";
<Mercury className="flex min-h-[480px] items-center justify-center">
  <h1 className="text-5xl font-semibold">Liquid metal</h1>
</Mercury>

Mercury is a container: whatever you put inside sits on top of the metal, in normal flow. It covers its own box edge to edge, so give it a height or content. The swells keep their size whatever the box, so a card shows a few and a full page many. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Demos

Tint

tintColor colours the metal and keeps its light and shade, here gold. Any CSS colour works: a pale blue gives titanium, a rose gives copper.

Preview width

Ripples

rippleScale sets the size of the swells: 2 gives a tight, disturbed surface and 0.6 a broad, still pool. intensity="subtle" lets more of the page through, so a card you put on top stays calm.

Preview width

Accessibility

The metal is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion the sheets hold still and the streak is hidden, so a still chrome surface stays. Nothing flashes: the streak is soft and crosses once every 13 seconds.

Put copy over it in your foreground colour (text-foreground). The metal's tones are kept in a range text can sit on: at the default intensity the foreground colour keeps about 6.4:1 on a light page and 4.5:1 on a dark one over the content area at the worst frame. intensity="strong" deepens the troughs and brightens the crests; check small text against it.

FAQ

How is the chrome look made?

A smooth noise field runs through a chrome curve: as the surface rises, the metal goes from shade to a bright band, back down and up to a white highlight, so every swell catches light on its shoulder and crest, as polished metal reflects its surroundings. A touch of fine grain before the curve keeps its gradients free of banding.

Does it run JavaScript or a canvas every frame?

No. The browser draws the two SVG sheets once, when the background first shows, and after that CSS keyframes slide and turn them on the compositor. They never scale, so they're never drawn again.

What does rippleScale do?

It sets the size of the swells: 1 by default, 0.6 for a broad, still pool and 2 for a tight, disturbed surface, from 0.4 to 3. It changes the texture itself, so nothing is stretched.

Can I make it gold or titanium?

Yes. tintColor colours the metal and keeps its light and shade, on both themes. highlightColor sets the colour of the highlights and the streak, white by default.

Does it work in dark mode?

Yes. On a dark page the metal is graphite with cool, dimmer highlights, its own set of tones rather than the light sheet darkened, so light text keeps its contrast.

How do I slow it down?

speed divides every duration: at 1 the sheets roll each way in 34 and 47 seconds and the streak crosses every 13; 0.5 is half as fast, 2 twice as fast.

API Reference

Mercury

<div> data-slot="mercury"

PropType
highlightColor?string

The colour of the highlights and the sweeping streak, any CSS colour.

Default
"white"
intensity?"subtle" | "medium" | "strong"

How strongly the metal shows over the surface: subtle behind body text, strong for a full chrome sheet.

Type
"subtle" | "medium" | "strong"
Default
"medium"
rippleScale?number

The size of the swells: 0.6 gives a broad, still pool, 2 a tight, disturbed surface.

Default
1
speed?number

How fast the metal rolls and the streak sweeps: 2 is twice as fast, 0.5 half as fast.

Default
1
tintColor?string

The metal's colour, any CSS colour, such as gold or titanium; left out, a cool silver (graphite on a dark page).

render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--mercury-highlightstring

The highlights' colour (white).

--mercury-speedstring

The motion's speed, a multiplier (1).

--mercury-tintstring

The metal's colour (a cool silver).

All 100 backgrounds