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

ModelViewer

model-viewer

Displays a CSS 3D model stage with drag rotation, inertia, parallax, and auto-rotate.

Usage

Basic usage

Put any children as a "model" on the stage - drag rotation, mouse parallax, hover tilt are all enabled by default.

Hu
tsx
<ModelViewer height={320}>
  {/* Any node can be used as a "model" */}
  <YourModel />
</ModelViewer>

Automatic rotation

autoRotate makes the model rotate at a constant speed around the Y axis, and autoRotateSpeed controls the angular velocity.

Hu
tsx
<ModelViewer height={320} autoRotate autoRotateSpeed={28}>
  <YourModel />
</ModelViewer>

Minimalist interaction

Turn off parallax/hover/contact shadow/reset buttons, leaving only pure drag rotation.

UI
tsx
<ModelViewer
  height={300}
  enableMouseParallax={false}
  enableHoverRotation={false}
  showContactShadow={false}
  showResetButton={false}
>
  <div
    className="grid size-32 place-items-center rounded-2xl text-4xl font-bold text-white"
    style={{
      background: "linear-gradient(135deg, var(--color-chart-2), var(--color-chart-5))",
      transform: "translateZ(40px)",
    }}
  >
    UI
  </div>
</ModelViewer>

When to Use

Use it to place any React node (a product image, card, SVG, or emoji) on a 3D stage with inertial drag rotation, parallax, hover tilt, and a contact shadow. It uses CSS 3D instead of three.js and does not load GLTF or FBX assets. For magnification, use Lens; for a glare-only hover effect, use GlareHover.

Import

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

Props

NameTypeDefaultDescription
widthnumber | string"100%"Stage width, constrained by outer container
heightnumber | string360Stage height
defaultRotationYnumber-20Initial yaw angle (around Y, °), accumulated when dragging
defaultRotationXnumber12Initial pitch angle (around X, °), accumulated when dragging
perspectivenumber1000CSS perspective depth in pixels; lower values create more exaggerated perspective
enableManualRotationbooleantrueAllow the mouse to drag and rotate, and let go to slow down with inertia
enableMouseParallaxbooleantrueMouse parallax (the model is slightly displaced when the pointer moves)
enableHoverRotationbooleantrueHover tilt (the model tilts towards the pointer)
autoRotatebooleanfalseAutomatically rotate around the Y-axis at a constant speed, superimposed with manual dragging
autoRotateSpeednumber24Rotation angular speed (°/s), only valid for autoRotate
showResetButtonbooleantrueShows the "Reset Perspective" button in the upper-right corner
showContactShadowbooleantrueShows a soft contact shadow beneath the content
classNamestring-Additional class name for the root container
styleCSSProperties-Inline styles forwarded to the root container

Slots

SlotTypeDescription
childrenReactNodePlace the "model" in the center of the 3D stage, and apply rotation/parallax/tilt uniformly through the components

Usage Guidelines

  • This is a CSS 3D stage, no real GLTF/FBX/OBJ is rendered; children should be flat/pseudo 3D content, the sense of depth comes from the outer preserve-3d sublayer itself using translateZ.
  • This is a client component because dragging and inertia use rAF. Under reduced motion, inertia and rotation are suppressed.
  • Contents that require transform-style: preserve-3d for multi-layer cubes must be set in children by yourself, and the component is only responsible for the overall rotation/parallax container.

Related

BorderBeam · ShineBorder · GlareHover · Lens · AnimatedBeam · OrbitingCircles

Playground

Hu
<div className="overflow-hidden rounded-xl"
     style={{ background: "oklch(0.16 0.02 255)" }}>
  <ModelViewer
    height={320}
    autoRotate={false}
    autoRotateSpeed={24}
    enableMouseParallax={true}
    enableHoverRotation={true}
    showContactShadow={true}
  >
    {/* Any children as "model" */}
    <YourModel />
  </ModelViewer>
</div>
PreviousLanyardDecorationNextFluidGlass

On this page

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