An absolutely positioned, mask-based gradient overlay that fades the primary color out from an edge or the center. Use it inside a relative container to give heroes and sections a soft background glow.
Install
pnpm dlx shadcn@latest add https://sitex.full.dev/r/gradient.jsonUsage
import { Gradient } from "@/components/ui/gradient"
export function Hero() {
return (
<section className="relative overflow-hidden">
<Gradient variant="radial" direction="top" className="opacity-30" />
<div className="relative">
<h1>Build sites fast</h1>
</div>
</section>
)
}Key details:
variantisradial(default) orlinear, implemented with CSS mask images.directionsets the gradient origin:left,right,top,bottom(default), orcenter.- The element fills its nearest positioned ancestor (
absolute inset-0), ispointer-events-none, and is hidden from assistive tech witharia-hidden. - It renders at 50% opacity with the
primarybackground color; override both viaclassName. gradientVariantsis exported for reusing the variant classes elsewhere.
The component is purely decorative and static, so it needs no client directive.