Hero Background
A full-bleed hero section on a live gradient that fades into the page.
Your headline
The gradient fades into the page.
import { HeroBackground } from "@/components/hero-background";
export function HeroBackgroundDemo() {
return (
<HeroBackground className="min-h-[400px]">
<h1 className="text-4xl font-semibold tracking-tight text-white">
Your headline
</h1>
<p className="mt-3 text-white/75">The gradient fades into the page.</p>
</HeroBackground>
);
}
Installation
pnpm dlx shadcn@latest add https://gradients.sh/r/hero-background.jsonUsage
import { HeroBackground } from "@/components/hero-background";
<HeroBackground>
<h1 className="text-5xl font-semibold text-white">Your headline</h1>
</HeroBackground>;The bottom edge fades into var(--background). Set fade={false} for a hard edge.
Props
| Prop | Type | Default |
|---|---|---|
childrenHero content, centred on top of the gradient. | ReactNode | — |
kindWhich gradient fills the component: one of the six free kinds, or any kind registered with the engine. | GradientKind | "mesh" |
fadeFade the bottom edge into var(--background). | boolean | true |
colorsTwo to six colours: hex, oklch(), names or var(--token). | [string, string, ...string[]] | ["#ecdcf2", "#8796ee", "#2e45b7", "#0e1645"] |
backgroundBase colour under the gradient. | string | "#0a0d24" |
speed0 to 2. How fast the gradient moves. 0 holds it still. | number | 0.6 |
loopSeconds4 to 30. The animation repeats exactly every loopSeconds. | number | 14 |
scale0.25 to 4. Noise frequency: higher means smaller shapes. | number | 1 |
warp0 to 1. Domain-warp strength. | number | 0.4 |
grain0 to 1. Film grain. | number | 0.1 |
blur0 to 1. Softness. | number | 0.45 |
seedInteger seed for the noise field. | number | 42 |
ditherOrdered 4×4 Bayer dither. | { enabled?: boolean; cell?: number; levels?: number } | { enabled: false, cell: 3, levels: 8 } |
interaction0 to 1 influence of the pointer and of scroll velocity. | { pointer?: number; scroll?: number } | { pointer: 0.3, scroll: 0.25 } |
maxDprDevice pixel ratio cap for the canvas. | number | 1.5 |
reducedMotion"respect" shows one still frame when the user prefers reduced motion. | "respect" | "ignore" | "respect" |
classNameClasses for the outer element. Size it here; the gradient fills it. | string | — |