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

Crosshair

crosshair

Tracks the pointer with configurable horizontal and vertical guide lines.

Usage

Basic usage

Component self-rendering absolute inset-0 is covered with the parent crosshair layer, and the following crosshair will appear when the mouse is moved into it.

Move the mouse here
tsx
<div
  className="relative h-56 overflow-hidden rounded-xl"
  style={{ background: "oklch(0.14 0.02 255)" }}
>
  <Crosshair />
</div>

Color and Thickness

color goes to token, thickness controls the line thickness.

Move the mouse here
tsx
<Crosshair color="var(--color-chart-1)" thickness={2} />

High viscosity tailing

Turn down smoothing to make the crosshair following more laggy and trailing more obvious.

Follow slowly · More obvious tailing
tsx
<Crosshair smoothing={0.06} color="var(--color-chart-3)" />

Turn off entry pulse

pulseOnEnter={false} removes the jitter pulse when entering, leaving only smooth following.

Move the mouse here
tsx
<Crosshair pulseOnEnter={false} color="var(--color-foreground)" />

When to Use

Use it when you need to display a crosshair that follows the pointer in a certain area (aiming/framing/technical style interactive area). It's a crosshair; if you want the cursor to jelly trail, use BlobCursor, to make clicks sparkle, use ClickSpark, to fill the screen with particles to absorb the background, use Antigravity.

Import

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

Props

NameTypeDefaultDescription
colorstringvar(--color-primary)Crosshair color (automatic light and dark theme), it is recommended to use token
smoothingnumber0.15Follow the smoothing coefficient (0-1), the smaller it is, the sticky and trailing it will be, the larger it will be, the more trailing it will be
thicknessnumber1Crosshair thickness (px)
pulseOnEnterbooleantrueTrigger a jitter pulse (CSS scale) when entering the container; invalid under reduced-motion, the following is still retained
classNamestring-Forwarded to the root container (must be positioning context, absolute inset-0 inside the component is filled with the parent)
styleCSSProperties-Forward inline styles to the root container

Usage Guidelines

  • The parent container must be a positioning context and have a clear height: the inside of the component is filled with absolute inset-0. If there is no positioning/no height, the crosshair will not be visible.
  • It is recommended to use the token color with the --color- prefix (var(--color-primary)) to ensure parsing. See [[hulian-token-color-var-needs-color-prefix]].
  • Enter pulse is disabled in reduced-motion, but pointer following is still retained.

Related

BorderBeam · ShineBorder · GlareHover · Lens · AnimatedBeam · OrbitingCircles

Playground

Move the mouse here
<div className="relative h-56 overflow-hidden rounded-xl"
     style={{ background: "oklch(0.14 0.02 255)" }}>
  <Crosshair
    smoothing={0.15}
    thickness={1}
    pulseOnEnter={true}
  />
</div>
PreviousClickSparkDecorationNextElectricBorder

On this page

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