瑚琏 Hulianv0.93.5413 组件0 组件
  • 开始
  • 组件
  • 区块
  • 页面
  • 模版
  • 更新
中文EN
  • 组件组件
  • 主题主题

背景

  • 点阵背景
  • 网格背景
  • 斜条纹背景
  • 径向辉光背景
  • 渐隐遮罩
  • 复古透视网格
  • 同心脉冲圆环
  • 流星雨
  • 极光渐变背景
  • 交互粒子场
  • 闪烁网格
  • 噪声波浪
  • 丝绸流动背景
  • 虹彩光泽背景
  • 流动丝线背景
  • 指针交互光球
  • 液态铬背景
  • 螺旋油彩
  • 彩球球池
  • 流动光柱
  • 多色流场
  • 暗色帷幕
  • 抖动波纹
  • 交互式点阵背景
  • 火焰邪眼
  • 故障终端雨
  • 铁磁流体
  • 漂浮线束
  • 视差星河
  • 渐变百叶窗
  • 颗粒渐变
  • 网格扭曲
  • 倾斜网格视差
  • 扫描网格
  • 跃迁隧道
  • 字符故障雨
  • 光束坠落
  • 电弧极光
  • 体积光柱
  • 光束放射
  • 波纹线阵
  • 液态色域
  • 点阵翻涌
  • 像素雪场
  • 等离子流动
  • 等离子波
  • 棱镜分光
  • 棱镜光爆
  • 雷达扫描
  • 涟漪网格
  • 几何网格
  • 侧光束
  • 柔和极光

覆盖特效

  • 边框光束
  • 流光边框
  • 反光悬停
  • 放大镜
  • 动效光束
  • 轨道环绕
  • 渐进模糊
  • 聚光卡片
  • 逐级揭示
  • 反重力粒子
  • 果冻光标
  • 点击火花
  • 准星十字线
  • 通电边框
  • 幽灵拖尾光标
  • 渐进贴边模糊
  • 光标图片拖尾
  • 激光束
  • 魔法光环
  • 指针磁吸
  • 磁力线网格
  • 黏液融球
  • 液态金属漆面
  • 轨道环绕
  • 像素余晖拖尾
  • 像素转场卡
  • 飘带跟随
  • 模糊形状高光
  • 流体溅射光标
  • 流星描边按钮
  • 可拖拽贴纸
  • 准星光标
  • 立方体阵列
  • 视差倾斜包裹器
  • 发光边框卡
  • 玻璃图标网格
  • 液态玻璃折射面
  • 挂绳工牌
  • 3D 模型舞台
  • 流体玻璃

LetterGlitch

letter-glitch

一片不断翻字变色的终端字符矩阵

用法

基础用法

放进 relative 深色容器,组件铺满并默认吃 chart token 调色板。

tsx
<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <LetterGlitch className="absolute inset-0" />
</div>

硬切故障感

smooth=false 关闭逐帧插值,字符颜色硬切,更生硬的故障雨。

tsx
<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <LetterGlitch className="absolute inset-0" smooth={false} glitchSpeed={40} />
</div>

中心暗角 + 置入内容

centerVignette 压暗中部反衬叠加文案,关掉 outerVignette。

GLITCH

tsx
<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <LetterGlitch className="absolute inset-0" outerVignette={false} centerVignette />
  <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
    <p className="text-lg font-semibold tracking-widest text-white">GLITCH</p>
  </div>
</div>

自定义调色板(终端绿/青)

glitchColors 传任意 CSS 颜色数组,离屏 canvas 解析后插值。

tsx
<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <LetterGlitch
    className="absolute inset-0"
    glitchColors={[
      "var(--color-chart-2)",
      "oklch(0.78 0.18 160)",
      "oklch(0.7 0.14 220)",
    ]}
    glitchSpeed={70}
  />
</div>

何时用

需要黑客终端 / Matrix 风格的字符故障雨背景时用。要纯几何点阵底纹用 DotPattern;要科技感网格扫描用 GridPattern。本组件是 canvas2d 字符矩阵,主打"翻字翻色"故障感。

导入

ts
import { LetterGlitch } from "@hulianui/ui"

Props

继承 HTMLAttributes<HTMLDivElement>(除 color),可透传 id / 事件等。
名称类型默认说明
glitchColorsstring[]["var(--color-chart-2)", "var(--color-chart-1)", "var(--color-chart-4)"]字符闪变调色板,任意 CSS 颜色,内部离屏 canvas 解析为 RGB 插值
glitchSpeednumber50相邻刷新最小间隔(ms),越小越躁动,建议 20-200
smoothbooleantrue颜色平滑过渡(逐帧插值);关闭后硬切,更生硬故障感
outerVignettebooleantrue外缘暗角(四周径向渐隐)
centerVignettebooleanfalse中心暗角(中部压暗→边缘透亮),用于反衬置入内容
charactersstring大写字母+符号+数字参与闪变的字符集,内部按码点拆分,支持任意 Unicode
classNamestring-透传根容器 className
styleCSSProperties-透传根容器内联样式

禁忌 / 坑

  • canvas2d 仅客户端,需在 client 组件树内使用;SSR 首帧空白属正常。reduced-motion 下降级。
  • 字符矩阵在深色底上才有终端观感,浅色容器对比度差。
  • glitchColors 传 CSS 变量须用 --color- 前缀 token,裸 var(--primary) 不解析,见 [[hulian-token-color-var-needs-color-prefix]]。

相关

DotPattern · GridPattern · StripedPattern · Spotlight · RetroGrid · Ripple

Playground

<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <LetterGlitch
    className="absolute inset-0"
    glitchSpeed={50}
    smooth={true}
    outerVignette={true}
    centerVignette={false}
  />
</div>
上一个跃迁隧道装饰下一个光束坠落

本页

  • 用法
  • 文档
    • 何时用
    • 导入
    • Props
    • 禁忌 / 坑
    • 相关
  • Playground