Skip to content

Gradient Text

Motion

Headline text filled with a slowly drifting gradient built from your accent tokens. A real text node for SEO and screen readers, still for reduced motion.

src/registry/premium/gradient-text.tsx/r/gradient-text.json

Installation

bash
npx shadcn@latest add @minidev/gradient-text

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/gradient-text.json

Usage

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

export function Example() {
  return (
    <GradientText />
  )
}

API reference

GradientText props
PropTypeDefault
childrenReact.ReactNode"Ship the whole product"
asElement to render. Use a heading tag when the text is the heading itself."span""h1""h2""h3""p""span"
durationSeconds per drift, one way.number8
colorsExtra colour stops; defaults to accent, accent-2 and back.string[]-
classNamestring-

When to use

Stays a real text node for SEO and screen readers, and holds still for reduced motion. Marketing only: the design law bans gradient text in product UI. Use it for one hero word or line; for a scramble-in effect use HyperText.

String children get the display size (text-4xl, 5xl from sm); pass a className text size to override it.

Accessibility

  • The text is text-transparent with a clipped background, so check contrast at both ends of the gradient against the page.
  • Under reduced motion the gradient is drawn but does not drift.

Frequently asked questions

Does gradient text hurt SEO or screen readers?

No. The words stay a real text node. Use as="h1" or as="h2" when the text is the heading, so the gradient is applied to the heading itself.

Why did my custom font size get ignored?

String children get text-4xl sm:text-5xl. Your className is merged after it, so a size class there wins. Non-string children get no size class.

Dependencies

npm

motion

Built from

No other MiniDev files

Examples

As a heading

as renders a real heading element, so the gradient line still works for SEO and screen readers.

Custom colours and speed

colors is the list of stops, tokens included; duration is seconds per drift, so a low value moves faster.

Inside a sentence

Match the size of the surrounding text with className to light up only a few words of a headline.

All Animated React components