Skip to content

GlitchText Glitch Tear Text ​

Neobrutalist-style glitch text effect that uses CSS clip-path to slice pseudo-elements, producing high-frequency displacement, chromatic aberration (RGB channel separation), and instant tear animations on trigger. Supports horizontal, vertical, and both tear directions.

Demo ​

Preview

悬停触发(默认)

残影闪烁

点击触发

点击我

自动播放

自动闪烁

速度变体

慢速中速快速

撕裂方向(点击切换查看)

水平垂直双向

自定义间隔 (interval=1000ms)

慢速间隔

手动控制 (trigger="none")

手动

Installation ​

pnpm dlx brutx-vue@latest add glitch-text

Usage ​

vue
<script setup>
import { GlitchText } from 'brutx-ui-vue'
</script>

<template>
    <GlitchText text="BRUTAL GLITCH" class="text-4xl" />
</template>

Variants ​

Trigger Modes ​

ModeDescription
hoverAnimation triggers on mouse hover, stops on mouse leave (default)
clickToggle animation on/off with click
autoplayAutomatically loops after component mount, pauses on hover
noneNo automatic trigger; use expose({ play(), stop() }) for external programmatic control

Speed Variants ​

SpeedCSS Variable Value
slow--glitch-duration: 800ms
medium--glitch-duration: 300ms (default)
fast--glitch-duration: 100ms

Tear Directions ​

Control tear slice and displacement direction via the direction prop:

DirectionDescription
horizontalHorizontal tear (default). Slices are horizontal, text is cut into horizontal strips, strips shift left/right, red-blue separation runs horizontally
verticalVertical tear. Slices are vertical, text is cut into vertical strips, strips shift up/down, red-blue separation runs vertically
bothBoth directions. ::before uses horizontal red, ::after uses vertical blue, two layers overlay for a more complex shattered effect
vue
<GlitchText text="HORIZONTAL" direction="horizontal" `trigger="click"` />
<GlitchText text="VERTICAL" direction="vertical" `trigger="click"` />
<GlitchText text="BOTH" direction="both" `trigger="click"` />

In both mode, both pseudo-elements overlay the original text. Color block stacking may reduce readability; use as needed.

Programmatic Control ​

Call play() or stop() through the component ref to control the active glitch state; see API Reference for complete member semantics.

API Reference ​

GlitchText — Props
NameTypeDefaultDescription
text
string | undefined
""
Text data for the glitch pseudo-elements. A non-empty value takes precedence over slot text for the animation layers.
Details

Declared type

string | undefined

Default value details

Resolved value
""

Source

GlitchText.vue:12

packages/ui/src/components/glitch-text/GlitchText.vue

trigger
"none" | "click" | "hover" | "autoplay" | undefined
"hover"
Selects the hover, click, autoplay, or none animation trigger.
Details

Declared type

"none" | "click" | "hover" | "autoplay" | undefined

Literal values

  • "autoplay"
  • "click"
  • "hover"
  • "none"

Default value details

Resolved value
"hover"

Source

GlitchText.vue:13

packages/ui/src/components/glitch-text/GlitchText.vue

interval
number | undefined
3000
The autoplay interval in milliseconds. The actual interval is clamped to the animation duration and minimum interval.
Details

Declared type

number | undefined

Default value details

Declaration
DEFAULT_AUTOPLAY_INTERVAL_MS

Source: packages/ui/src/components/glitch-text/GlitchText.vue

Resolved value
3000

Source

GlitchText.vue:14

packages/ui/src/components/glitch-text/GlitchText.vue

speed
"fast" | "medium" | "slow" | undefined
"medium"
Selects the slow, medium, or fast visual pace of the glitch animation.
Details

Declared type

NonNullable<"slow" | "medium" | "fast" | null | undefined> | undefined

Literal values

  • "fast"
  • "medium"
  • "slow"

Default value details

Resolved value
"medium"

Source

GlitchText.vue:15

packages/ui/src/components/glitch-text/GlitchText.vue

direction
"both" | "horizontal" | "vertical" | undefined
"horizontal"
Selects horizontal, vertical, or bidirectional glitch displacement.
Details

Declared type

NonNullable<"vertical" | "horizontal" | "both" | null | undefined> | undefined

Literal values

  • "both"
  • "horizontal"
  • "vertical"

Default value details

Resolved value
"horizontal"

Source

GlitchText.vue:16

packages/ui/src/components/glitch-text/GlitchText.vue

class
string | undefined
undefined
Custom CSS classes appended to the root text span.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

GlitchText.vue:17

packages/ui/src/components/glitch-text/GlitchText.vue

GlitchText — Events
NameSignature or typeDescription
@mouseenter
MouseEvent
The root span’s native mouseenter event is available to consumers through Vue attribute fallthrough; the component does not declare a custom event with this name.
  • In hover mode, activates the glitch effect; in autoplay mode, pauses the timer. Other modes do not change internal state.
Details

Declared type

MouseEvent

Source

GlitchText.vue

packages/ui/src/components/glitch-text/GlitchText.vue

@mouseleave
MouseEvent
The root span’s native mouseleave event is available to consumers through Vue attribute fallthrough; the component does not declare a custom event with this name.
  • In hover mode, clears the glitch effect; in autoplay mode, resumes the timer. Other modes do not change internal state.
Details

Declared type

MouseEvent

Source

GlitchText.vue

packages/ui/src/components/glitch-text/GlitchText.vue

@click
MouseEvent
The root span’s native click event is available to consumers through Vue attribute fallthrough; the component does not declare a custom event with this name.
  • A click toggles the glitch state only in click mode; clicks do not change internal state in other trigger modes.
Details

Declared type

MouseEvent

Source

GlitchText.vue

packages/ui/src/components/glitch-text/GlitchText.vue

GlitchText — Slots
NameSignature or typeDescription
#default
{}
Renders text content and supports inline styling. The visible content prefers this slot and falls back to text; the glitch pseudo-elements prefer non-empty text and otherwise extract text from the slot.
Details

Declared type

{}

Source

GlitchText.vue

packages/ui/src/components/glitch-text/GlitchText.vue

GlitchText — Exposes
NameSignature or typeDescription
play
() => void
Manually activates the glitch state regardless of trigger mode; reduced-motion preference still hides the visual animation. The autoplay timer continues independently.
Details

Declared type

() => void

Source

GlitchText.vue:92

packages/ui/src/components/glitch-text/GlitchText.vue

stop
() => void
Manually clears the active glitch state; the autoplay timer continues on its own schedule.
Details

Declared type

() => void

Source

GlitchText.vue:93

packages/ui/src/components/glitch-text/GlitchText.vue

Accessibility ​

  • With trigger="click", the root receives button semantics, keyboard focus, and aria-pressed, and supports Enter / Space to toggle; other trigger modes do not set button semantics
  • The component disables glitch animation when prefers-reduced-motion: reduce is active

Brute force builds.