LibraryEffects

InteractiveDotText

Any text drawn as a field of dots that react to the pointer.

InteractiveDotText

Status: internal
Package path: packages/effects/src/interactive-dot-text/
Import: @ziteox/effects/interactive-dot-text

Renders a line of text as dots. Dots near the pointer push away and switch to the highlight colour, then ease back when the pointer moves on. The text scales to the width of its container, whatever the string. Hover the previews with a mouse to try it.

Preview

InteractiveDotText · defaults

Usage

import { InteractiveDotText } from "@ziteox/effects/interactive-dot-text";

export function Signature() {
  return <InteractiveDotText text="Hello" />;
}

By default it uses the surrounding font and text colour. Set them explicitly when needed:

<InteractiveDotText
  text="Launch"
  fontFamily='"Space Grotesk Variable", sans-serif'
  color="#0B0E0F"
  highlightColor="#21AB70"
/>

Example preset: ziteox.com

The large wordmark at the bottom of ziteox.com: faded top to bottom, at 40% opacity, with muted greens. It is an example, not the default.

InteractiveDotText · ziteox.com preset
<InteractiveDotText
  text="ZITEOX"
  fontFamily='"Space Grotesk Variable", sans-serif'
  letterSpacing={-0.02}
  color="#F1F0EB"
  highlightColor="#2A9E6E"
  highlightColorAlt="#1B7350"
  fade
  opacity={0.4}
  decorative
/>

Props

PropTypeDefaultDescription
textstringrequiredThe text to draw, one line
fontFamilystringinheritedFont stack; load the font in your app
fontWeightnumber700Font weight
letterSpacingnumber0Letter spacing in em
colorstring--zx-dot-text-color, then the inherited text colourDot and glyph colour
highlightColorstring--zx-dot-text-highlight, then #3BEA9CColour of dots the pointer disturbs
highlightColorAltstring--zx-dot-text-highlight-alt, then highlightColorSecond highlight colour, mixed in at random
fadebooleanfalseFade from solid at the top to faint at the bottom
opacitynumber1Opacity of the whole element
densitynumber1Dot density multiplier
reachnumber0.3Pointer reach as a multiple of the rendered font size
decorativebooleanfalseHide from assistive tech; otherwise the text is its accessible name
className / styleOn the wrapper

Behaviour

  • A static SVG of the text renders first (server-safe); on devices with a mouse it switches to the dot canvas.
  • Touch devices and prefers-reduced-motion: reduce keep the static text.
  • The canvas animates only while the text is on screen.
  • Colours set through CSS variables are re-read while it runs, so a theme switch applies without a remount.