Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Text

Pro

Glitch Text for React

Text that glitches like a corrupted signal, bands of it tearing away and jumping sideways in red and cyan. For React with Base UI, when a headline should look broken on purpose.

Framework

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.

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

Preview width

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.

Preview width

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

Which font suits it?

Any, but a heavy weight or a monospaced font, such as font-mono, gives the slices more to tear. It takes the size, weight and colour of the text around it.

What happens with reduced motion?

The text is plain and still; the glitch never plays.

API Reference

GlitchText

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

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

CSS variableType
--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).

All 97 text effects