Glitch Text
Single-burst RGB channel split and horizontal clip-path slicing on hover or text change, with fine-pointer gating and imperative burst control.
SIGNAL LOCKED
Customize
Installation
npx shadcn@latest add @kinetic/glitch-textUsage
Pass a string to text. By default, GlitchText fires a short single burst whenever a fine pointer enters or when text changes, pairing a damped shake on the main layer with two horizontally sliced chromatic ghost layers. It runs once per trigger and never loops indefinitely.
import { GlitchText } from "@/components/kinetic/ui/glitch-text";
interface SignalHeadingProps {
readonly label: string;
}
export function SignalHeading({ label }: SignalHeadingProps) {
return (
<GlitchText
as="h2"
text={label}
className="text-3xl font-semibold tracking-tight"
/>
);
}Triggers and intensity
Control when a burst runs with trigger: "hover", "change", "both" (default), or "manual". Hover bursts are gated by pointer: fine so touch devices do not misfire on tap.
Use intensity (default 6, clamped 1 to 16) to tune horizontal channel displacement in pixels and main-layer shake amplitude, and durationMs (default 320, clamped 120 to 800) to set the burst length.
import { GlitchText, type GlitchTextTrigger } from "@/components/kinetic/ui/glitch-text";
interface StatusLabelProps {
readonly status: string;
readonly trigger: GlitchTextTrigger;
}
export function StatusLabel({ status, trigger }: StatusLabelProps) {
return (
<GlitchText
text={status}
trigger={trigger}
intensity={8}
durationMs={360}
className="font-mono text-lg font-medium"
/>
);
}Imperative control
Attach a GlitchTextHandle ref to call trigger() or cancel() directly. Calling trigger() cancels any active burst before starting a new one so rapid interactions stay crisp.
import { useRef } from "react";
import { GlitchText, type GlitchTextHandle } from "@/components/kinetic/ui/glitch-text";
interface BurstTriggerProps {
readonly label: string;
}
export function BurstTrigger({ label }: BurstTriggerProps) {
const ref = useRef<GlitchTextHandle>(null);
return (
<div className="flex items-center gap-3">
<GlitchText ref={ref} text={label} trigger="manual" className="text-xl font-semibold" />
<button type="button" onClick={() => ref.current?.trigger()}>
Trigger
</button>
<button type="button" onClick={() => ref.current?.cancel()}>
Cancel
</button>
</div>
);
}Accessibility and reduced motion
The main text layer uses SplitText to expose a single screen-reader string (overridable with aria-label) while marking split spans aria-hidden="true". Both RGB channel ghost layers carry aria-hidden="true", pointer-events-none, and select-none, so assistive technology reads the text once and text selection stays clean.
durationMs and speed scale with the global Kinetic tempo. When reduced motion is active via browser preference or data-reduced-motion="true", GlitchText cancels any running burst, keeps both ghost layers hidden, and invokes onComplete immediately.
API Reference
GlitchText
Single-burst RGB split and sliced clip-path text component backed by WAAPI and the shared shake helper.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | - | Visible text content. |
trigger | "hover" | "change" | "both" | "manual" | "both" | Events that fire a single glitch burst. |
intensity | number | 6 | Horizontal RGB channel shift in pixels (clamped 1 to 16). |
durationMs | number | 320 | Duration of the single burst in milliseconds (clamped 120 to 800). |
speed | number | 1 | Speed multiplier combined with global tempo. |
onComplete | () => void | - | Called once the burst finishes or settles immediately under reduced motion. |