Gradient text

Free · MIT

Text filled with a slowly drifting multi-stop gradient, with Aurora, Sunset, Ocean and theme palettes tuned separately for light and dark.

MarkdownOpen in v0
Open in v0

Installation

$ npx shadcn@latest add https://goodui.dev/r/gradient-text.json

The file lands in components/goodui/gradient-text.tsx and is yours to edit. With the @goodui registry added, npx shadcn@latest add @goodui/gradient-text works too.

Usage

import { GradientText } from "@/components/goodui/gradient-text"

export function Hero() {
  return (
    <h1 className="text-5xl font-bold tracking-tight">
      Bookings that <GradientText>run themselves</GradientText>
    </h1>
  )
}

When to use

Use it for
  • One or two key words in a hero headline ("Bookings that run themselves", with only the last two words in gradient).
  • A product or plan name that should carry the brand colors.
  • When the same gradient must look good in light and dark: the presets have separate, deeper light-mode colors.
Reach for something else
  • A heading that only needs a gradient: heading with treatment="gradient" (or emphasis="gradient" for the _italic_ words) is simpler and keeps size, font and tone in one component.
  • A light sweep on muted text: use shiny-text.
  • Body copy, links and small labels: gradients lower legibility at small sizes. Use text with a tone.
If you needUse
Cool, techypalette="aurora" (default)
Warm, friendlypalette="sunset"
Calm bluespalette="ocean"
Follow the theme's chart colorspalette="brand"
Exact brand colorscolors={["#…", "#…", "#…"]}
Static gradientanimate={false}

Examples

Brand palette, static

<GradientText palette="brand" animate={false} className="font-semibold">
  Brightside Pro
</GradientText>

Custom colors, slower drift

<GradientText colors={["#7c3aed", "#db2777", "#f59e0b"]} duration={14}>
  Black Friday: 40% off annual plans
</GradientText>

API reference

PropTypeDefault
palette
Theme-aware preset. "brand" follows the theme's chart colors.
"aurora" | "sunset" | "ocean" | "brand""aurora"
colors
Custom stops; overrides `palette`. The first color is repeated at the end for a seamless loop.
string[]—
animate
Move the gradient.
booleantrue
duration
Seconds per loop.
number8

Also accepts every <span> attribute.

Accessibility

  • The text stays real text; only the paint is a gradient, so screen readers and copy-paste are unaffected.
  • Light-mode presets use deeper colors and dark-mode presets brighter ones, chosen to keep the text readable on each background. Check contrast yourself for custom colors.
  • Browsers without background-clip: text show the first palette color as a solid text color.

Motion

  • The gradient (200% wide) drifts horizontally in a seamless linear loop, one cycle every `duration` s (8).
  • Text that wraps onto several lines gets the gradient per line (box-decoration-break: clone).
  • Reduced motion: the gradient stops moving and stays visible.
  • Pure CSS (background-position animation); no JavaScript runs.

Notes for AI

Coding agents read these rules through MCP and llms.txt, or paste this page with Copy page.

  • Wrap only the words that need emphasis, not whole paragraphs.
  • Do not add text-* color classes; the color comes from the gradient. Pick a palette or pass colors.
  • colors needs at least two colors; the first is repeated at the end so the loop is seamless. One color is ignored.
  • Custom colors apply in both themes; pick colors that work on light and dark or use a preset.

FAQ

Heading treatment="gradient" or GradientText?

For a whole heading, or emphasized words in it, the Core heading is simpler. GradientText works inline in any element and adds four palettes, custom colors and a drifting animation.

Does "brand" follow my theme?

Yes, it uses --chart-1, --chart-2, --chart-4 and --chart-5 from your theme.

Related