Gradient Button
A button with a live gradient fill and hover, press, focus and disabled states.
import { GradientButton } from "@/components/gradient-button";
export function GradientButtonDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-3">
<GradientButton size="sm">Small</GradientButton>
<GradientButton>Get started</GradientButton>
<GradientButton size="lg">Large</GradientButton>
</div>
);
}
Installation
pnpm dlx shadcn@latest add https://gradients.sh/r/gradient-button.jsonUsage
import { GradientButton } from "@/components/gradient-button";
<GradientButton onClick={start}>Get started</GradientButton>;It takes every native button attribute, such as disabled, onClick and type.
Props
| Prop | Type | Default |
|---|---|---|
childrenThe label, optionally with an icon. | ReactNode | — |
kindWhich gradient fills the component: one of the six free kinds, or any kind registered with the engine. | GradientKind | "mesh" |
sizeHeight and padding. | "sm" | "md" | "lg" | "md" |
typePlus every other native button attribute, such as disabled and onClick. | "button" | "submit" | "reset" | "button" |
colorsTwo to six colours: hex, oklch(), names or var(--token). | [string, string, ...string[]] | ["#5b3df0", "#9b2fd9", "#c2255c", "#2f5fd9"] |
backgroundBase colour under the gradient. | string | "#3b1fd1" |
speed0 to 2. How fast the gradient moves. 0 holds it still. | number | 0.9 |
loopSeconds4 to 30. The animation repeats exactly every loopSeconds. | number | 14 |
scale0.25 to 4. Noise frequency: higher means smaller shapes. | number | 1.3 |
warp0 to 1. Domain-warp strength. | number | 0.4 |
grain0 to 1. Film grain. | number | 0 |
blur0 to 1. Softness. | number | 0.4 |
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, scroll: 0 } |
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 | — |