Background Gradient, animated React component
Wraps a card or button in a slowly turning conic-gradient ring with a soft glow underneath. Hover and the ring spins up while its centre leans toward the pointer; press and the card squashes, springs back past its size and the glow flashes.
- Free
- Background Effects
- Hover
- Spring
- Glow
Like Background Gradient? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Background Gradient stays free.
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Pro
Popular$18 / month
Unlimited projects, team seats and priority builds.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | Content inside the ring. |
| className | string | — | Classes for the outer wrapper (width, layout). |
| containerClassName | string | — | Classes for the content wrapper; put padding here. |
| surfaceClassName | string | — | Classes for the inner surface. White, or #1c1c1e in dark mode, by default. |
| colors | string[] | ["#0a84ff", "#5e5ce6", "#bf5af2", "#ff375f", "#ff9f0a"] | Ring colours in order round the edge. Two or more. |
| animationSpeed | number | 1 | Spin speed multiplier, 0.2 to 3. |
| blur | number | 24 | Blur of the glow under the card, in px. |
| borderRadius | string | "24px" | Corner radius of the wrapper. |
| ringWidth | number | 1.5 | Thickness of the gradient ring, in px. |
| as | "div" | "button" | "section" | "div" | Root element. "button" adds keyboard focus and press feedback. |
| interactive | boolean | true | Spin up and lean toward the pointer on hover, squash on press. |
| disabled | boolean | false | Disables the button variant. |
| onClick | () => void | — | Click handler for the button variant. |
| aria-label | string | — | Accessible name for the button variant when its content is not plain text. |
| autoplay | boolean | false | Circles a pretend pointer round the card until someone hovers it. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry
Run this once per project. It writes the Nexus UI entry into
components.jsonfor you:npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"Type it exactly as shown.
{name}is filled in by the CLI with the component you ask for, so you never replace it.
- 3
Add the component
Run this from your project root. It adds the component, the helpers it imports and its npm packages.
npx shadcn@latest add @nexus-labs/background-gradient
- 4
Check what was added
With a project made as in the Quick Start (a
src/folder), these files land in it:components/background-gradient.tsxbackground-gradient/background-gradient.tsxindex.ts - 5
Copying by hand? Skip the registry
Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that
cn()exists. Install the packages:npm install framer-motion
Then show the source and create each file at the path it gives:
- 6
Use it in a page
Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:
// src/app/page.tsx import { BackgroundGradient } from "@/components/background-gradient"; export default function Page() { return ( <main> <BackgroundGradient /> </main> ); }
Like Background Gradient? 256 more are in Pro.
Pro unlocks all 256 Pro components, every template and block, and everything we release next. Background Gradient stays free.
About Background Gradient
The Background Gradient component renders an animated radial or mesh gradient that shifts colors on a timer using CSS keyframe animation. Gradient stops, colors, position, and animation speed are configurable via props. Works as a hero section background, card fill, or full-page backdrop. Because the animation runs with CSS rather than JavaScript, it has no performance impact on React render cycles or scroll event handling.
Good for
- Hero section animated backgrounds
- Card and panel background fills
- Section backdrop color effects
- Promotional and campaign page backgrounds