# Gradient Text

> 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.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/gradient-text
- Source (registry JSON with the full file): https://ui.minidev.pro/r/gradient-text.json
- License: MIT. One file, yours to edit after install.

## 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.

## Installation

### shadcn CLI (copies the source into your project)

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

Writes `components/ui/gradient-text.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/gradient-text.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

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

From the npm package:

```tsx
import { GradientText } from "minidev-ui-kit/premium/gradient-text"
```

## Usage

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

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

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `children` | `React.ReactNode` | `"Ship the whole product"` | no |  |
| `as` | `"span" \| "h1" \| "h2" \| "h3" \| "p"` | `"span"` | no | Element to render. Use a heading tag when the text is the heading itself. |
| `duration` | `number` | `8` | no | Seconds per drift, one way. |
| `colors` | `string[]` | - | no | Extra colour stops; defaults to accent, accent-2 and back. |
| `className` | `string` | - | no |  |

## Examples

### As a heading

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

```tsx
<GradientText as="h2">Invoices that close themselves</GradientText>
```

### Custom colours and speed

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

```tsx
<GradientText colors={["var(--success)", "var(--info)", "var(--success)"]} duration={4}>
  Paid in 140 currencies
</GradientText>
```

### Inside a sentence

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

```tsx
<p className="max-w-lg text-center text-3xl font-medium tracking-[-0.03em] text-fg">
  Lumen makes <GradientText className="text-3xl font-medium tracking-[-0.03em] sm:text-3xl">getting paid</GradientText> the easy part of running Northwind
</p>
```

## 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.

## FAQ

### 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.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Hyper Text](https://ui.minidev.pro/docs/hyper-text/md): A React text effect that scrambles characters through random glyphs and settles them left to right on mount or hover, in monospace so the width never jumps.
- [Masked Gradient Headline](https://ui.minidev.pro/docs/masked-gradient-headline/md): A gradient text headline that wipes in from left to right with a clip path reveal when it scrolls into view. Accepts any children as the heading text.
- [Sparkles Text](https://ui.minidev.pro/docs/sparkles-text/md): Headline text with four point stars that twinkle around it in your accent colors. The sparkles are decorative and hidden; the text stays plain and readable.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.
- [Cursor Spotlight Panel](https://ui.minidev.pro/docs/cursor-spotlight-panel/md): A panel whose accent radial spotlight follows the cursor, driven by Framer Motion values without re-renders. It shows a still surface for reduced motion.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
