Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Reflection Background for React

Still water at dusk: a calm horizon, long wisps of cloud drifting across a soft sky, and a lake that mirrors it all with slow ripples and the shimmering path of a low sun. For React with Base UI, when a hero, travel or wellness page wants a quiet, open view behind its copy.

Framework

Still water at dusk: a calm horizon with a low line of distant hills, long wisps of cloud drifting slowly across a softly layered sky, and a lake that mirrors all of it, darker with depth, crossed by slow ripples and the shimmering path of a low sun. It follows your colour scheme, a pastel dawn on a light page and a night lake under a moon glow and a few stars on a dark one. It's CSS with no script: the sky and its mirror are one static gradient, and each cloud is a strip of noise drawn once that slides sideways by exactly one tile, so the loop never jumps. Its reflection is the same strip flipped about the horizon, with the ripples drawn into it once, on the same keyframes, so the two stay in step. Only transforms and opacity animate.

Use it behind a hero, a travel or retreat page, or a calm product page, with the copy in the sky or on the water. For curtains of light in the sky, without the lake, use Aurora; for a rolling sea out to the horizon, Ocean; for the view from below the surface, Underwater; for sunlight on a pool floor, Caustics.

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 { Reflection } from "@/components/ui/reflection";
<Reflection className="flex min-h-[480px] flex-col items-center pt-20 text-center">
  <h1 className="text-5xl font-semibold">Still water</h1>
</Reflection>

Reflection is a container: whatever you put inside sits on top of the scene, in normal flow. It paints its own sky and water, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Demos

Low horizon

horizon sets where the horizon sits, as a share of the height from the top, from 0.2 to 0.8. At 0.34 the lake takes most of the box; clarity={0.85} makes it a clearer mirror and intensity="subtle" calms the ripples, a quiet place for copy.

Preview width

Sunset

colors takes up to four CSS colours: the sky overhead, the sky half-way down, the glow at the horizon and the sun. Here a dusky violet, rose, a deep amber glow and a warm sun; the water, the clouds and the ripples are mixed from them, and the same colours are used in both colour schemes.

Preview width

Accessibility

The scene is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion the clouds, the ripples and the sun's path stop where they are, and the still sky with its reflection stays. Nothing flashes: the sun's path brightens and dims over about four seconds.

Put copy over it in your foreground colour (text-foreground). With the default colours it keeps above 8:1 everywhere on a light page, where the dawn is pale, and above 6:1 over the start half of a dark page, where the lake is dark; only the moon and the brightest glints of its path dip below 4.5:1. The sun (or moon) sits on the end side of the horizon, on the right or, on a right-to-left page, the left, so keep small text away from it. If you pass your own colors, check your copy against the lightest and darkest of them.

FAQ

How does the reflection stay in step with the sky?

Each cloud is drawn twice: once in the sky and once in a copy flipped about the horizon and squashed to 90% of its height, as a reflection is. Both copies use the same strip of noise, slide by the same tile on the same keyframes and start together, so every wisp and its reflection move as one. The ripples in the reflection are drawn into it once, so nothing is filtered while it moves.

Can I move the horizon?

Yes: horizon takes 0.2 to 0.8, 0.5 by default. A low value, around 0.35, gives you more water, a calm place for a headline; a high one gives more sky. The far shore, the sun and the mirror all follow it.

What does clarity do?

It sets how clearly the water mirrors the sky: 0.3 is murky, the reflection fading quickly into deep water, and 1 a near-perfect mirror. The default is 0.7.

How do I change the palette?

Pass up to four CSS colours in colors: the sky overhead, half-way down, the glow at the horizon and the sun. Any you leave out keep their defaults, which are a pastel dawn on a light page and a night lake on a dark one. You can also set --reflection-color-1 to --reflection-color-4 in your CSS.

Can I hide the sun?

sun={false} removes the glow at the horizon and its path on the water, for an overcast evening. The clouds, the ripples and the mirror stay.

What does intensity change?

How strongly the ripples and the sun's path glint on the water: subtle for glassy water behind long text, strong for a breezier evening. The sky stays the same.

Is it heavy?

No. There's no canvas and no script: a static gradient, three clouds, their reflections, four bands of ripples and two layers of the sun's path, each drawn once and moved by transforms the browser composites without repainting. Every loop is a long one, so the page's main thread stays asleep.

API Reference

Reflection

<div> data-slot="reflection"

PropType
clarity?number

How clearly the water mirrors the sky: 0.3 is murky and dark, 1 a near-perfect mirror.

Default
0.7
colors?string[]

Up to four CSS colours: the sky overhead, the sky half-way down, the glow at the horizon and the sun (or moon). Any you leave out keep their defaults: a pastel dawn on a light page, a night lake on a dark one.

horizon?number

Where the horizon sits, as a share of the height from the top, from 0.2 to 0.8.

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

How strongly the ripples and the sun's path glint on the water.

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

How fast the clouds drift and the ripples slide: 2 is twice as fast, 0.5 half as fast.

Default
1
sun?boolean

Whether a low sun (a moon on a dark page) glows at the horizon, with its shimmering path across the water.

Default
true
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
--reflection-claritystring

How clearly the water mirrors the sky (0.7).

--reflection-color-1string

The sky overhead (periwinkle; deep navy on a dark page).

--reflection-color-2string

The sky half-way down (rose; indigo on a dark page).

--reflection-color-3string

The glow at the horizon (peach; moonlit blue on a dark page).

--reflection-color-4string

The sun, or the moon, and its path (pale gold; silver on a dark page).

--reflection-horizonstring

Where the horizon sits, from the top (0.5).

--reflection-speedstring

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

All 100 backgrounds