Installation
Add a moving gradient to a React app in three steps.
gradients.sh installs through the shadcn CLI, so it works in any React project shadcn supports: Next.js, Vite, React Router, TanStack Start and others.
For Next.js specifics (Server Components, layouts, static export), see WebGL gradient backgrounds in Next.js.
1. Set up shadcn
Skip this if your project already has a components.json.
npx shadcn@latest init2. Add a component
pnpm dlx shadcn@latest add https://gradients.sh/r/mesh-gradient.jsonThis adds components/mesh-gradient.tsx, the shared components/gradient-surface.tsx and the engine in lib/gradient-engine/. The next component you add reuses the surface and the engine.
3. Use it
import { MeshGradient } from "@/components/mesh-gradient";
export function Hero() {
return (
<MeshGradient className="h-[480px]">
<h1 className="p-12 text-5xl font-semibold text-white">Ship faster</h1>
</MeshGradient>
);
}Start your dev server. The heading sits on a slowly moving gradient. For a full landing page hero with theme colours, see Animated gradient background for shadcn/ui.
Install by name
Add the registry to components.json once:
{
"registries": {
"@gradients": "https://gradients.sh/r/{name}.json"
}
}Then install any free component by name:
npx shadcn@latest add @gradients/auroraPro components
Pro components install with the gradients.sh CLI instead. It sets up shadcn if needed and logs your computer in the first time:
npx gradients.sh add god-raysSee Pro components.