UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

Animate UI/Gradient Background

Backgrounds
1 of 10
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

10 versions·2 libraries

  • Gradient Background
  • Bubble Background
  • Fireworks Background
  • Glyph Background
  • Gravity Stars Background
  • Hexagon Background
  • Hole Background
  • Stars Background
  • Topography Background
  • Cult UI

Gradient Background

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

npx shadcn@latest add https://animate-ui.com/r/backgrounds-gradient.json
Open in v0 Docs Repo
Library
Animate UI
License
MIT + Commons Clause

Free to use in your apps; you can’t resell the components themselves.

Stack
React · Tailwind CSS · animated
Packages
@animate-ui/reactcnmotion
Size
59 lines

Code

@components/animate-ui/backgrounds/gradient.tsx

'use client';

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

import { usePageVisible } from '@animate-ui/react/utils/use-page-visible';
import {
  ReducedMotionConfig,
  useShouldReduceMotion,
} from '@animate-ui/react/utils/motion';
import { cn } from 'cn';

type GradientBackgroundProps = HTMLMotionProps<'div'>;

const STATIC_POSITION = '0% 50%';

function GradientBackgroundContent({
  ref,
  className,
  transition = { duration: 15, ease: 'easeInOut', repeat: Infinity },
  ...props
}: GradientBackgroundProps) {
  const localRef = React.useRef<HTMLDivElement>(null);
  React.useImperativeHandle(ref, () => localRef.current as HTMLDivElement);

  const inView = useInView(localRef);
  const pageVisible = usePageVisible();
  const reduce = useShouldReduceMotion();
  const playing = inView && pageVisible && !reduce;

  return (
    <motion.div
      ref={localRef}
      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: playing
          ? [STATIC_POSITION, '100% 50%', STATIC_POSITION]
          : STATIC_POSITION,
      }}
      transition={playing ? transition : { duration: 0 }}
      {...props}
    />
  );
}

function GradientBackground(props: GradientBackgroundProps) {
  return (
    <ReducedMotionConfig>
      <GradientBackgroundContent {...props} />
    </ReducedMotionConfig>
  );
}

export { GradientBackground, type GradientBackgroundProps };

More like this

Safari Browser

Eldora UI·Media & 3D

Drape Background

Kokonut UI·Backgrounds

Bubble Background

Animate UI·BackgroundsMIT+

Noise Texture

Magic UI·Backgrounds

Ribbons

React Bits·Cursor & effectsMIT+

Glow Effect

Motion Primitives·Cursor & effects

Aspect Ratio

shadcn/ui·Data display

Card Nav

React Bits·NavigationMIT+

Map

Eldora UI·Media & 3D

Novatrix Background

Eldora UI·Backgrounds

Halftone Background

Kokonut UI·Backgrounds

Glyph Background

Animate UI·BackgroundsMIT+

Grid Pattern

Magic UI·Backgrounds

Holo Card

React Bits·CardsMIT+

Gravity Stars Background

Animate UI·BackgroundsMIT+