Gradient Text
Eye-catching gradient headline text with background-clip.
Gradient headlines that demand attention.
<h2 class="text-3xl md:text-5xl font-black tracking-tight"> <span class="bg-gradient-to-r from-indigo-600 via-purple-600 to-pink-600 bg-clip-text text-transparent">Gradient headlines</span> <span class="block text-slate-900 dark:text-white mt-2">that demand attention.</span> </h2>
Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
Sunset
Warm gradients suit food, travel, and lifestyle landing pages.
Warm gradients that feel like golden hour.
Ocean
Cool gradients fit SaaS and fintech heroes that want calm confidence.
Cool gradients with calm confidence.
On dark
Use the dark-panel version when the hero sits on a dark background.
Gradient headlines that glow in the dark.
About this gradient text
Gradient text is the hero-typography technique behind countless landing pages: bold headlines where key words flow from one brand color to another. The CSS behind it is background-clip: text, which Tailwind exposes as bg-clip-text with text-transparent. The gradient paints the text instead of the box.
This snippet pairs a gradient line with a solid line, which is the classic hero pattern. The gradient draws the eye to the emotional word ("Gradient headlines") while the solid line carries the message. Keep gradient text to a few words: full paragraphs in gradient are hard to read.
For dark mode, brighten the gradient stops. from-indigo-400 via-purple-400 to-pink-400 pops on dark backgrounds where the 600 shades look muddy. And always check contrast: decorative gradient words should not carry critical information alone.
Hero headlines have one job: make the visitor feel something within three seconds. Solid-color headlines all look alike, so the eye skips them. A gradient on the emotional words creates a focal point the eye lands on first, which is why this pattern pairs a gradient line (the feeling) with a solid line (the message). The color flow draws attention; the solid text delivers meaning.
The span gets bg-gradient-to-r from-indigo-600 via-purple-600 to-pink-600 bg-clip-text text-transparent. Background-clip: text clips the gradient to the shapes of the glyphs, and text-transparent lets it show through, so the gradient paints the letters instead of the box. The second line stays text-slate-900: it carries the readable message while the gradient line carries the emotion.
Direction changes the mood: to-r feels energetic, to-br feels dynamic, to-b feels calm. On dark backgrounds, shift the stops brighter (indigo-400 instead of 600) because the 600 shades turn muddy against dark. For a living headline, set background-size to 200% and animate background-position in slow keyframes for a shimmer that never distracts.
The readability mistake is gradienting the entire headline, including the functional words, so nothing stands out and the whole thing gets harder to read. The power of the pattern is the pairing: gradient on two to five emotional words, solid on the rest. Contrast between the lines is what makes the gradient line pop.
Where to use it
- ✓ Hero section headlines
- ✓ Feature highlight words
- ✓ Pricing tier names
- ✓ Section dividers
Customization tips
Try different gradient directions: bg-gradient-to-br for diagonal, or animate the gradient position for a shimmering headline. Limit gradient text to 2-5 words for readability.
Design notes
When to use
Use it for hero headlines where two to five gradient words carry the emotion while a solid line carries the message. The color flow draws the eye to the key phrase first. It shines on landing pages, feature headers, and pricing tier names.
What to avoid
Do not set whole paragraphs in gradient text; long gradient passages are tiring to read. Do not pick low contrast gradients where the lightest stop fades into the background.
Accessibility
Background-clip text can disappear in Windows high contrast or forced colors mode, so provide a solid color fallback. Keep gradient text short and never use it for the only instance of critical information.
Frequently asked questions
How do I make gradient text in CSS?
Apply a background gradient to the text element, then use background-clip: text with color: transparent. In Tailwind: bg-gradient-to-r from-indigo-600 to-pink-600 bg-clip-text text-transparent.
Does gradient text work in all browsers?
background-clip: text is supported in all modern browsers. Very old browsers show transparent (invisible) text, so provide a solid-color fallback for critical headlines.
Is gradient text bad for accessibility?
It can reduce contrast. Check the lightest part of your gradient against the background, and do not rely on gradient words alone for essential information.
How do I add a fallback color for gradient text?
Set a solid text color first, then layer the gradient with background-clip: text and transparent color on top. Browsers without support ignore the clipped layer and show the solid color. Pick a mid-tone from your gradient so the fallback still looks intentional.
How do I animate gradient text?
Set background-size to 200% or more on the gradient, then animate background-position in keyframes so the colors slide through the text. Keep bg-clip-text and text-transparent in place during the animation. A 4 to 6 second ease-in-out infinite loop looks smooth without being distracting.
Why does my gradient text show as a solid color in Safari?
Safari needs the -webkit- prefixed properties: -webkit-background-clip: text and -webkit-text-fill-color: transparent. Tailwind's bg-clip-text includes the prefix in recent versions, but if you wrote custom CSS you must add both prefixes yourself. Test on real Safari, not just responsive mode, since rendering differs.
Related elements
Typography sets the tone of a page before a single word is read. A drop cap pulls the eye into the opening paragraph and gives long-form content an editorial feel with no images and no extra markup. It is a small detail that makes articles feel designed rather than dumped.
Drop Cap
Editorial paragraph with an oversized drop cap on the first letter.
OUTLINED
Outlined Text
Large display heading with transparent fill and a crisp text stroke outline.
Build interfaces faster.
Typewriter Effect
CSS-only tailwind typewriter effect with a blinking cursor.