Presets

Gradient shift button

A button filled with a slowly drifting multi-color gradient.

CSSTailwindReactGIFMP4
trigger: loop
00.000 / 6.000s
timing
style
content
20 max

npm i motion · the component uses motion/react

How it works

The gradient shift button fills its background with a three-color linear gradient that slides back and forth, so the colors appear to flow across the label. It is common on upgrade and pricing buttons, where a bit of color movement suggests something premium.

The background is linear-gradient(Angle, Color 1, Color 2, Color 3) with background-size set to 300% 300%, so the gradient is three times larger than the button and only a third of it is visible at once. The shift keyframe moves background-position from 0% 50% to 100% 50%, and animation-direction: alternate plays it back the other way instead of jumping to the start. The result is a smooth loop with no seam.

Parameters: Label, Color 1, Color 2, Color 3, Text color, Corner radius, Angle and Duration, plus Easing. Pick colors with similar lightness so the label stays readable as the gradient moves; dark text on lime, cyan and lilac works, while mixing yellow with navy does not. Keep Duration at 3s or slower for a calm drift. An Angle of 90deg moves colors horizontally; 45deg gives a diagonal sheen.

Background-position is not composited, so the button repaints every frame. On a single button that cost is tiny. Check text contrast against every color in the gradient, not just the first one, since the label sits on all three at some point in the loop.

Why is background-size 300%?

The gradient has to be larger than the button for background-position to move anything. At 300% only one third of the gradient fits in the button, and shifting the position from 0% to 100% slides the visible window across all three colors. Smaller sizes give subtler movement; larger sizes make each color band wider and the motion slower.

Can I use this gradient animation on a larger background?

Yes, the technique is identical. The Animated gradient background preset applies it to a large panel with an 8 second default loop, which suits hero sections. Keep in mind that repainting a full-width section costs more than a button, so prefer slow durations there.

Can I animate the gradient only on hover?

Move the animation into a :hover rule in the CSS output, or use hover:animate-[...] in Tailwind. Alternatively keep the gradient static and transition background-position on hover from 0% to 100%, which gives a one-time sweep. In React, put the background position in a whileHover variant.

relatedMore like this

all buttons →
01 Loading button loop
02 Shine sweep button loop
03 Pulse glow button loop
04 3D press button press
05 Border draw button hover

Export

format
height

480p max · small watermark · 3 per day · remove limits