Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Backgrounds

  • DotPattern
  • GridPattern
  • StripedPattern
  • Spotlight
  • FadeMask
  • RetroGrid
  • Ripple
  • Meteors
  • Aurora
  • Particles
  • FlickeringGrid
  • WavyBackground
  • Silk
  • Iridescence
  • Threads
  • Orb
  • LiquidChrome
  • Balatro
  • Ballpit
  • Beams
  • ColorBends
  • DarkVeil
  • Dither
  • DotField
  • EvilEye
  • FaultyTerminal
  • Ferrofluid
  • FloatingLines
  • Galaxy
  • GradientBlinds
  • Grainient
  • GridDistortion
  • GridMotion
  • GridScan
  • Hyperspeed
  • LetterGlitch
  • Lightfall
  • Lightning
  • LightPillar
  • LightRays
  • LineWaves
  • LiquidEther
  • PixelBlast
  • PixelSnow
  • Plasma
  • PlasmaWave
  • Prism
  • PrismaticBurst
  • Radar
  • RippleGrid
  • ShapeGrid
  • SideRays
  • SoftAurora

Overlay Effects

  • BorderBeam
  • ShineBorder
  • GlareHover
  • Lens
  • AnimatedBeam
  • OrbitingCircles
  • ProgressiveBlur
  • CardSpotlight
  • Reveal
  • Antigravity
  • BlobCursor
  • ClickSpark
  • Crosshair
  • ElectricBorder
  • GhostCursor
  • GradualBlur
  • ImageTrail
  • LaserFlow
  • MagicRings
  • Magnet
  • MagnetLines
  • MetaBalls
  • MetallicPaint
  • OrbitImages
  • PixelTrail
  • PixelTransition
  • Ribbons
  • ShapeBlur
  • SplashCursor
  • StarBorder
  • StickerPeel
  • TargetCursor
  • Cubes
  • Tilt
  • BorderGlow
  • GlassIcons
  • GlassSurface
  • Lanyard
  • ModelViewer
  • FluidGlass

Particles

particles

Animates a canvas particle field with pointer repulsion and theme-aware foreground color.

Usage

Basic usage

Put it into the relative container. Particles comes with absolute and inset-0. If color is not transferred, the theme foreground color will be used, and the mouse will be magnetically displaced when approaching it.

Particles
tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <Particles quantity={120} />
  <div className="grid h-full place-items-center text-sm text-muted-foreground">Particles</div>
</div>

Still and slow motion

staticity The bigger the particle is, the less likely it is to follow the mouse. The larger ease is, the slower it will follow, creating a more restrained atmosphere.

staticity=80 ease=80
tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <Particles quantity={80} staticity={80} ease={80} />
</div>

Specify color

Pass color (#hex / rgb()) to fix the particle color and no longer follow the theme.

color=#6366f1
tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <Particles quantity={100} color="#6366f1" />
</div>

Particle size and drift

size increases the single particle radius, and vx / vy gives a constant drift speed to form a directional flow.

size=2 vx=0.3
tsx
<div className="relative h-48 w-80 overflow-hidden rounded-xl border border-border bg-surface">
  <Particles quantity={50} size={2} vx={0.3} vy={0.1} />
</div>

When to Use

Use it when you need a stardust/particle background that interacts with the mouse (technical Hero, login page). Based on canvas, it has mouse rejection and drift interaction, which is more dynamic but more expensive than pure CSS Aurora; if you only want a static color gradient background, use Aurora; if you want regular dot matrix/grid shading, use DotPattern / GridPattern.

Import

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

Props

NameTypeDefaultDescription
quantitynumber100Number of particles
staticitynumber50Static coefficient, the larger it is, the less likely it is to follow the mouse (displacement = mouseOffset / (staticity/magnetism))
easenumber50Easing coefficient, the larger it is, the slower it is (translateX += (target-current)/ease)
sizenumber0.4Particle base radius (px), finally random in [size, size+2]
colorstring--color-foregroundParticle color. When omitted, the component reads the theme token and responds to data-theme; explicit values accept #rrggbb, #rgb, or rgb(r,g,b)
vxnumber0X-axis constant drift speed (px/frame)
vynumber0Y-axis constant drift speed (px/frame)
refreshboolean | number | string-Refresh signal - force redrawing of particles when the value changes (equivalent to MagicUI refresh)
classNamestring-Additional class name for the container div

Usage Guidelines

  • Canvas color prop only accepts #rrggbb/#rgb/rgb() parsing format, cannot directly pass var(--token) or oklch string - if you want a theme color, do not pass color and let it read --color-foreground internally, or parse it into rgb first and then pass it (see [[oklch-css-var-color-must-parse-via-offscreen-canvas]]).
  • Based on canvas, client rendering is required; the parent container requires relative + overflow-hidden.
  • There is a performance cost to redrawing frame by frame if the quantity is too large (quantity is hundreds or more), and the background layer should be controlled as appropriate.

Related

DotPattern · GridPattern · StripedPattern · Spotlight · RetroGrid · Ripple

Playground

Particles
<div className="relative overflow-hidden">
  <Particles
    quantity={100}
    staticity={50}
    ease={50}
    size={0.4}
  />
</div>
PreviousAuroraDecorationNextFlickeringGrid

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Usage Guidelines
    • Related
  • Playground