Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Text

Pro

Colourful Text for React

Text whose letters each wear a colour and swap it in a wave, blurring for a moment as they change. For React with Base UI, when one word should feel lively and playful.

Framework

Colourful Text gives every letter of a word its own colour, no two neighbours alike, and every few seconds a wave runs through it: each letter, as the wave reaches it, blurs and lifts for a moment and comes back in its next colour. It never stops, but it's calm between waves, so the word stays easy to read.

Use it for one word in a headline that should feel playful: a creative tool, a kids' product, a celebration. For a continuous ribbon of colour that rolls through the letters, use Rainbow Text; for your brand's colours flowing as one gradient, Gradient Text; for a wave of light, Shimmering Text. It's CSS only and nothing is random: each letter is clipped to a strip of every colour and a keyframe animation the install adds to your stylesheet steps along it, while a second one hides each change behind the blur. With reduced motion the letters keep their colours and stay still.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { ColourfulText } from "@/components/ui/colourful-text";
<h2>
  The most <ColourfulText text="colourful" /> components you'll find
</h2>

Demos

Colors

colors is the palette, any CSS colours, at least two, including your theme's variables such as var(--primary). Each letter steps through all of them in turn, starting a few colours on from its neighbour. By default it's ten hues at one lightness, darker on a light page and lighter on a dark one.

Preview width

Timing

duration is how long the letters hold each colour, 4000 ms by default, and stagger the time between one letter changing and the next, 60 ms: a long stagger makes a slow wave you can follow along the word.

Preview width

Accessibility

Screen readers read the word once, as plain text: the coloured letters are hidden from them, and a visually hidden copy carries the word. Words wrap whole and keep their direction on a right-to-left page. The colours share one lightness by default, so each letter is as readable as the next; in forced-colors mode the letters fall back to the system's text colour. The wave pauses while the pointer is over the text, and with reduced motion it doesn't run.

FAQ

Are the colours random?

No. Each letter starts a fixed number of colours on from its neighbour and steps through the palette in order, so the server and the browser draw the same colours and no two neighbours ever match.

How does a letter change colour without JavaScript?

Each letter is filled with a strip of every colour side by side, clipped to its shape and as wide as the letter times the number of colours. A keyframe animation slides the strip one colour at a time with steps(), and a second animation blurs and lifts the letter at each step, so the jump happens out of focus.

How is it different from Rainbow Text?

Rainbow Text is one smooth ribbon of hues that rolls through the word all the time. Colourful Text gives each letter one solid colour and changes them in a wave every few seconds.

Can I use it on a sentence?

Keep it to a word or a short phrase: every letter is its own element, and a sentence of changing colours is hard to read.

Why does it stop under the pointer?

So anyone who finds the movement distracting can stop it, as WCAG asks of anything that keeps moving for more than five seconds. The letters keep their current colours and come back into focus.

What happens with reduced motion?

The letters keep their colours, each different from its neighbours, and nothing moves or changes.

API Reference

ColourfulText

<span> data-slot="colourful-text"

PropType
textstring

The text.

colors?string[]

The colours the letters take, any CSS colours (at least two): each letter steps through them in turn, its neighbours a few colours ahead. By default ten hues at the theme's lightness.

Default
DEFAULT_COLORS
duration?number

How long the letters hold each colour, in milliseconds.

Default
4000
stagger?number

The time between one letter changing colour and the next, in milliseconds: the wave that runs through the word.

Default
60
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--colourful-text-countstring
--colourful-text-durationstring

How long the letters hold each colour (4s).

--colourful-text-lightnessstring

The default colours' oklch lightness (0.6, 0.78 in dark mode).

--colourful-text-shiftstring
--colourful-text-staggerstring

The time between one letter changing and the next (60ms).

  • Pro

    Rainbow Text

    Decorative

    One ribbon of colour rolling through

  • Gradient Text

    Decorative

    Your brand's colours as one gradient

  • Shimmering Text

    Decorative

    A wave of light, not colour

  • Pro

    Foil Text

    Decorative

    Rainbows that move with the pointer

  • Pro

    Wave Text

    Motion

    Letters that ride a playful wave

  • Pro

    Pop Text

    Entrance

    Letters that pop in with a burst

All 97 text effects