Dot Matrix <mv-dot-matrix>

Grille WebGL de points carrés : au chargement, ils s’allument du centre vers l’extérieur avec une brève étincelle, puis chaque point tire à nouveau sa luminosité au hasard, à ses propres moments, pour un scintillement paisible, quelques points d’accent respirent avec plus d’éclat, et une zone plus vive s’ouvre autour du pointeur. Autonome (aucun runtime de shader à installer), il se met en pause hors écran, partage le budget de contextes WebGL de la page et affiche une grille fixe entièrement révélée en mouvement réduit.

CatégorieArrière-plans
TypeÉlément WebGL (<mv-dot-matrix>)
Statutstable
Keywordswebgl, shader, dots, matrix, reveal, grid, flicker, hero

When to use

  • A hero or launch section should reveal a colorful dot grid from the center on load
  • A tech or data brand wants a calm flickering dot field that brightens around the pointer

Avoid when

  • A static or CSS-only dot texture is enough, e.g. behind docs or app screens → use Dot Pattern instead
  • A quiet dot texture should fade out behind a section title with no script at all → use Backdrop instead

Installation

node scripts/add.mjs dot-matrix --out ./src/marvelous

Agent IA avec le serveur MCP de Marvelous UI : install_components({ slugs: ["dot-matrix"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Fichiers copiés (dépendances comprises) : tokens/tokens.css, core/base.css, core/canvas.js, core/dom.js, core/element.js, core/motion.js, core/observe.js, core/webgl.js, components/dot-matrix/dot-matrix.js, components/dot-matrix/dot-matrix.css.

Utilisation

Balisage de référence : partez de celui-ci et personnalisez-le avec les attributs, data-* et les variables CSS :

<mv-dot-matrix data-fill></mv-dot-matrix>
<div style="position:relative;display:grid;place-items:center;height:100%;min-height:320px;color:white;text-align:center;pointer-events:none">
  <div>
    <p style="margin:0;font:700 clamp(1.6rem,4vw,2.6rem)/1.1 var(--mv-font-sans);letter-spacing:-.03em;text-shadow:0 4px 24px rgb(0 0 0 / .45)">Every signal, one grid</p>
    <p style="margin:.5rem 0 0;opacity:.8;font-size:.9rem">&lt;mv-dot-matrix spacing="10"&gt;</p>
  </div>
</div>

API

Attributes

NameTypeDefaultDescription
colorsCSS colors (3)var(--mv-accent), #38bdf8, #e879f9Dot palette: main tint, then the two accent colors (tokens accepted, re-read on theme change).
dot-sizenumber2.5Dot side length, in CSS pixels.
spacingnumber10Grid pitch, in CSS pixels.
revealnumber1.6Duration of the reveal from the center (seconds per unit of distance, one unit being the element's height).
flickernumber1Flicker speed (0 = dots hold their level).
accentnumber0.025Share of brighter accent dots (0 to 0.5).
hover-radiusnumber0.3Radius of the zone that wakes up around the pointer (fraction of the height).
speednumber1Time multiplier.
pausedbooleanFreezes the grid on the current frame (fully revealed if paused from the start).
interactivebooleanOnly pointer moves over the element itself count; by default the window is watched, so content on top does not block the hover zone.
dprnumber1.5Max pixel density (capped at 2).
data-fillbooleanFills the positioned parent (absolute, inset 0).

Content structure

NameDescription
childrenContent placed inside the element sits above the grid.

Accessibility

Decorative: the canvas is aria-hidden and never takes pointer events. The loop stops off screen and in hidden tabs; reduced motion (OS or <html data-motion="reduce">) and paused show a still, fully revealed grid with no hover zone. Without WebGL2 a still CSS dot grid is shown; forced colors and print hide the canvas.

Cette page a été traduite par IA. Signaler un problème de traduction