shadcn.io is not affiliated with official shadcn/ui
Flickering Text makes a line flicker like a tube that's about to go: some letters hold steady while others dip dim or blink, each on its own irregular rhythm, so the pattern never looks mechanical. It's brightness only: no letter moves or changes colour.
Use it for a short headline with a late-night, run-down feel, on its own or with a glow of your own. For a sign that works, with a halo and a single tired letter, use Neon Text; for text that tears and jumps, Glitch Text. It's CSS only: each flickering letter runs one of three keyframe rhythms of abrupt dips, added to your stylesheet by the install, its length and phase worked out from its place, so it looks random while the server and the browser draw the same. No letter dips more than three times a second, it steadies while the pointer is over it, and with reduced motion it doesn't flicker.
Installation
Usage
import { FlickeringText } from "@/components/ui/flickering-text";<h2>
<FlickeringText text="No vacancy tonight" />
</h2>Demos
Intensity
intensity is how hard it flickers: subtle dims a few letters a little, and rarely; medium, half of them, to a third of their brightness; strong, nearly all of them, nearly dark and more often.
Glow
Flickering Text changes only the letters' opacity, so a glow of your own flickers with them: give the text a text-shadow in currentColor, here on a sky-blue sign.
Accessibility
Screen readers read the text once, from a visually hidden copy; the flickering letters are hidden from them. No letter dips more than three times a second, the whole line steadies while the pointer is over it, and with reduced motion it holds still at full brightness. Words wrap whole, and the line keeps its direction on a right-to-left page.
FAQ
Is the flicker random?
It looks random but isn't: which letters flicker, their rhythm, its length and its phase all come from a small formula of each letter's place, so the server and the browser draw the same and the page never mismatches.
Is it safe for people sensitive to flashing?
No letter dips more than three times a second, the threshold the accessibility guidelines set, at any intensity, and it's off entirely when the system asks for reduced motion.
How do I set its colour?
It takes the text's colour, so set it on the text or the element around it, such as className="text-sky-500". A dip is a drop in opacity, so any colour flickers the same way.
How do I add a neon glow?
Give the text a text-shadow in currentColor, such as [text-shadow:0_0_0.15em_currentColor]: each letter's glow dims with it. For a full sign, with a halo that breathes, use Neon Text.
API Reference
FlickeringText
<span> data-slot="flickering-text"
textstring
The text.
intensity?"subtle" | "medium" | "strong"
How hard the letters flicker: how dim they drop and how often, from a rare dip to a failing tube.
- Type
"subtle" | "medium" | "strong"- Default
"medium"
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.
--flickering-text-dipstring
How dim a letter drops, an opacity (0.35).
--flickering-text-durationstring
One round of a letter's rhythm, about (4s).
Related
- Pro
Neon Text
DecorativeA working sign with a halo
- Pro
Glitch Text
DecorativeText that tears and jumps
- Pro
Fuzzy Text
DecodeStatic that shakes the letters
- Pro
Chromatic Text
DecorativeRed and cyan fringes that breathe
- Pro
Dot Matrix Text
DecorativeA sign lit from a grid of dots
- Pro
Breathe in, breathe out
Breathing Text
MotionA calm fade in and out instead