shadcn.io is not affiliated with official shadcn/ui
Glitch Text tears a line like a bad signal: in short bursts, bands of the text jump sideways, fringed in red and cyan, then snap back into place. Between the bursts it's plain and readable. It can glitch all the time, or only while the pointer is over it.
Use it for a headline or a label with a digital, broken edge: an error page, a game, a launch teaser. For colours that split without tearing, use Chromatic Text; for text that resolves out of noise, Decrypted Text. It's CSS only: two copies of the text, each clipped to a band, are the torn slices, and the real text is masked where they tore; one keyframe animation, added to your stylesheet by the install, steps the bands through registered CSS properties, at most six changes a second. Nothing paints a background, so it works over any surface. With reduced motion the text is plain.
Installation
Usage
import { GlitchText } from "@/components/ui/glitch-text";<h1>
<GlitchText text="Signal lost" />
</h1>Demos
Hover
trigger="hover" glitches only while the pointer is over the text, starting with a burst the moment it arrives. On a touch screen, where there's no hover, the text stays plain.
Intensity
intensity is how far the torn slices jump: subtle, medium or strong. duration is one round of bursts, 3000 ms by default; a shorter round glitches more often, but never under 2000 ms.
Accessibility
The text stays real text, read once by screen readers and selectable; the torn slices are copies hidden from them and from the pointer. The glitch never changes more than six times a second, three flashes at most, and with reduced motion it doesn't play. In forced-colors mode the slices are dropped and the text is plain.
FAQ
Does it need a background behind it?
No. The bands are cut out of the real text with a mask, not covered with a colour, so it works on any surface: a card, an image, a gradient.
Is it safe for people sensitive to flashing?
Yes, within the guidelines: a round of the glitch changes at most six times in any second, three flashes, at the shortest duration, and it doesn't play at all when the system asks for reduced motion.
Is the glitch random?
No: a round is the same set of tears each time, at uneven moments, so it reads as irregular while the server and the browser draw the same.
Can I change the red and cyan?
Yes: set --glitch-text-left and --glitch-text-right on the text or around it, to any CSS colours, such as your theme's var(--chart-1).
API Reference
GlitchText
<span> data-slot="glitch-text"
textstring
The text.
duration?number
One round of the glitch, a burst of tears and a later one, in milliseconds; never under 2000, so it never flashes more than three times a second.
- Default
3000
intensity?"subtle" | "medium" | "strong"
How far the torn slices jump sideways. @default "medium".
- Type
"subtle" | "medium" | "strong"- Default
"medium"
trigger?"loop" | "hover"
When it glitches: all the time, or while the pointer is over it. @default "loop".
- Type
"loop" | "hover"- Default
"loop"
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.
--glitch-text-a1string--glitch-text-a2string--glitch-text-axstring--glitch-text-b1string--glitch-text-b2string--glitch-text-bxstring--glitch-text-durationstring
One round of the glitch (3s).
--glitch-text-leftstring
The colour fringing the slice that jumps left (red).
--glitch-text-rightstring
The colour fringing the slice that jumps right (cyan).
--glitch-text-shiftstring
How far a slice jumps (0.06em at medium).
Related
- Pro
Chromatic Text
DecorativeColours that split without tearing
- Pro
Decrypted Text
DecodeText that resolves out of noise
- Pro
Fuzzy Text
DecodeAnalogue static instead of tears
- Pro
Flickering Text
DecorativeA failing sign that dips and blinks
- Pro
Scrambled Text
DecodeGlyphs that churn under the pointer
- Pro
Shatter Text
InteractiveLetters that break into shards