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

Cubes

cubes

Renders an interactive field of perspective cubes with animated depth.

Usage

Basic usage

Default 8×8 cube array: The cube that the pointer is close to is attenuated and tilted according to the distance, and automatically wanders when idle. Click to spread the ripples outward. Containers need to be of given size.

tsx
<div className="h-56 w-56">
  <Cubes />
</div>

Grid density

gridSize controls the array side length (the number of DOM is square, recommended ≤ 12); cooperates with maxAngle / radius to adjust the tilt amplitude and influence radius.

tsx
<div className="h-56 w-56">
  <Cubes gridSize={12} maxAngle={60} radius={4} />
</div>

Brand color ripples

faceColor / edgeColor / rippleColor Eat all token; click to spread the highlight outwards from the hit point in a circular shape, rippleSpeed to control the diffusion speed.

tsx
<div className="h-56 w-56">
  <Cubes
    faceColor="var(--color-surface)"
    edgeColor="var(--color-primary)"
    rippleColor="var(--color-chart-2)"
    rippleSpeed={3}
  />
</div>

Still (turn off automatic wandering)

autoAnimate={false} Turn off idle roaming, the cube only tilts when the pointer interacts, and stays flat normally.

tsx
<div className="h-56 w-56">
  <Cubes gridSize={6} autoAnimate={false} />
</div>

When to Use

Use it when you need a grid background/decorative panel with a 3D feel that responds to pointer tilt. It is suitable for visual embellishment of hero areas, empty consoles, and active landing pages. It is a regular grid array; if you want a softer particle/spot type atmosphere background, look at other effects background components; if you want a single element to hover and emit light, use GlareHover.

Import

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

Props

NameTypeDefaultDescription
gridSizenumber8Grid side length (row = column), generate gridSize² cubes; DOM is square level, recommended ≤ 12
cubeSizenumber-Single cube side length (px); when passed in, the container has a fixed size, otherwise the container will adapt (width 100%·1:1)
maxAnglenumber45The maximum tilt angle of the cube at the pointer (degrees), the closer it is, the bigger it is and the farther it is, the closer it is to 0
radiusnumber3Tilt influence radius (in "grid"), participate in tilt within the range, and return to normal outside
cellGapnumber | { row?: number | string; col?: number | string }"5%"Unit spacing, numbers in px, objects specify rows and columns respectively (percentage strings scale with the container)
faceColorstringvar(--color-surface)Cube face background color, must be prefixed with --color-
edgeColorstringvar(--color-border)Cube surface border color
rippleColorstringvar(--color-primary)The ripple highlight color that spreads outward from the hit point when clicked
rippleSpeednumber2Ripple diffusion speed multiplier, the bigger the faster
autoAnimatebooleantrueWhether to automatically wander and tilt when idle (automatically disabled to remain stationary under reduced-motion)
rippleOnClickbooleantrueWhether to enable click ripples
classNamestring-Forward the additional class name of the root container
styleCSSProperties-Forward the root container inline style

Usage Guidelines

  • When cubeSize is omitted, the container uses a responsive 1:1 aspect ratio. Give its parent explicit dimensions, for example with a fixed-width, fixed-height wrapper, or the container may collapse.
  • All color props (faceColor/edgeColor/rippleColor) must be tokenized with the --color- prefix. See [[hulian-token-color-var-needs-color-prefix]].
  • The number of DOMs is gridSize². Don’t set gridSize too large (recommended ≤ 12), otherwise the number of nodes and rearrangement costs will soar.
  • Under reduced-motion, autoAnimate automatically fails and the cube becomes stationary.

Related

BorderBeam · ShineBorder · GlareHover · Lens · AnimatedBeam · OrbitingCircles

Playground

<div className="h-56 w-56">
  <Cubes
    gridSize={8}
    maxAngle={45}
    radius={3}
    rippleSpeed={2}
    autoAnimate={true}
    rippleOnClick={true}
  />
</div>
PreviousTargetCursorDecorationNextTilt

On this page

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