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

背景

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

覆盖特效

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

FlickeringGrid

flickering-grid

让网格里的方块随机明灭,透出技术感

用法

基础用法

放进 relative + overflow-hidden 容器,用 absolute inset-0 铺满;默认吃主题前景色,4px 方格随机闪烁。

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid className="absolute inset-0" />
</div>

自定义颜色

color 支持 CSS 变量,传强调色 token 并调高 maxOpacity 让网格更醒目。

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid className="absolute inset-0" color="var(--color-primary)" maxOpacity={0.5} />
</div>

方格大小与间距

squareSize / gridGap 决定网格密度,调大方格 + 降低 flickerChance 得到沉稳的大格闪烁。

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={8}
    gridGap={4}
    flickerChance={0.1}
    maxOpacity={0.4}
  />
</div>

高频密集闪烁

小方格 + 高 flickerChance 模拟数据流/赛博质感。

tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={2}
    gridGap={2}
    flickerChance={0.7}
    maxOpacity={0.25}
  />
</div>

何时用

需要科技感/数据感的像素方格背景,且方格随机明灭闪烁时用。基于 canvas,自带 ResizeObserver 跟随容器尺寸;若要静态规则网格(不闪烁、更轻),用 GridPattern;若要点阵用 DotPattern;若要复古透视网格用 RetroGrid。

导入

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

Props

继承 HTMLAttributes<HTMLDivElement>,额外:

名称类型默认说明
squareSizenumber4每个方格边长(px),越小越密
gridGapnumber6方格间距(px)
flickerChancenumber0.3每帧每格闪烁概率(乘 deltaTime)。0=静态网格,1=高频闪烁
maxOpacitynumber0.3方格最大不透明度(0~1),越高越明显
colorstring--color-foreground方格颜色,任意 CSS 颜色字符串。不传则从容器 color/token 解析 RGB 随主题切换
widthnumber-固定宽度(px)。不传用 ResizeObserver 跟随容器宽
heightnumber-固定高度(px)。不传用 ResizeObserver 跟随容器高

禁忌 / 坑

  • 基于 canvas,须客户端渲染;父容器需 relative + overflow-hidden,组件自身用 absolute inset-0 铺满。
  • 不传 width/height 时靠 ResizeObserver 跟随容器,故容器必须有确定尺寸(高度别塌成 0)。
  • color 可传 var(--color-*),组件会逐帧 getComputedStyle 解析(与只吃 rgb 的 Particles 不同),但每帧解析有微小成本。

相关

DotPattern · GridPattern · StripedPattern · Spotlight · RetroGrid · Ripple

Playground

<div className="relative h-48 w-80 overflow-hidden rounded-xl">
  <FlickeringGrid
    className="absolute inset-0"
    squareSize={4}
    gridGap={6}
    flickerChance={0.3}
    maxOpacity={0.3}
  />
</div>
上一个交互粒子场装饰下一个噪声波浪

本页

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