Gradient Background

PreviousNext

A background component featuring a subtle yet engaging animated gradient effect, smoothly transitioning colors to enhance visual depth.

Docs
animate-uiui

Preview

Loading preview…
registry/components/backgrounds/gradient/index.tsx
'use client';

import * as React from 'react';
import { motion, type HTMLMotionProps } from 'motion/react';

import { cn } from '@/lib/utils';

type GradientBackgroundProps = HTMLMotionProps<'div'>;

function GradientBackground({
  className,
  transition = { duration: 15, ease: 'easeInOut', repeat: Infinity },
  ...props
}: GradientBackgroundProps) {
  return (
    <motion.div
      data-slot="gradient-background"
      className={cn(
        'size-full bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500 bg-[length:400%_400%]',
        className,
      )}
      animate={{ backgroundPosition: ['0% 50%', '100% 50%', '0% 50%'] }}
      transition={transition}
      {...props}
    />
  );
}

export { GradientBackground, type GradientBackgroundProps };

Installation

npx shadcn@latest add @animate-ui/components-backgrounds-gradient

Usage

import { ComponentsBackgroundsGradient } from "@/components/ui/components-backgrounds-gradient"
<ComponentsBackgroundsGradient />