Text FX JS behaviour

Media-masked text

Media runs inside exhibition-size glyphs: three animated patterns — dots, fish-scale waves, checkerboard — swap on one switch and march beneath the letters by exactly one tile a step; the sibling line loops a harbour-dusk scene gradient.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The exhibition word, hollowed out

The glyphs are a window: whatever media sits behind them shows through, clipped by background-clip. The march advances the background by exactly one tile a step, so dots, scales and checks loop without a seam — and the Persian word carries the same mask untouched.

TIDE & STONE · ROTTERDAM DESIGN WEEK

CURRENTS

Harbour dusk — the scene gradient sibling

Oct 14–18 · Fenix Museum Curators: Maastricht & Oslo studios

Every step moves the background by one full tile of the active pattern — that is the whole secret of the seamless loop.

Important props

Important props
Prop Type Default What it does
background-clip technique 'text' The pattern clips onto the glyphs themselves with transparent ink; the tiles size through background-size.
pattern attribute 'dots' Three patterns via data-pat on the root: dots (radial-gradient), fish-scale waves (two offset radials) and a checkerboard (repeating-conic-gradient).
march keyframes '1 tile / step' A seamless march: the background-position animation advances by exactly that pattern’s tile, so the loop never shows a seam.
scene gradient 'dusk' The sibling line trades the pattern for a multi-stop harbour-dusk gradient, drifting slowly over a 200% background.
reduced-motion media 'frozen' Under prefers-reduced-motion the march and drift stop; the pattern or gradient rests, fully visible.

Snippet

<div class="mmx" x-data="{ pat: 'dots' }" x-bind:data-pat="pat">
    <div class="mmx-chips" role="group" aria-label="Pattern inside the letters">
        <button type="button" x-bind:aria-pressed="pat === 'dots' ? 'true' : 'false'" x-on:click="pat = 'dots'">Dots</button>
        <button type="button" x-bind:aria-pressed="pat === 'waves' ? 'true' : 'false'" x-on:click="pat = 'waves'">Waves</button>
        <button type="button" x-bind:aria-pressed="pat === 'checks' ? 'true' : 'false'" x-on:click="pat = 'checks'">Checker</button>
    </div>

    <h2 class="mmx-word" aria-label="CURRENTS">CURRENTS</h2>
    <p class="mmx-scene">Tide &amp; Stone · Rotterdam · Oct 14–18</p>
</div>

<style>
.mmx { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.mmx-word, .mmx-scene {
    margin: 0; color: transparent;
    -webkit-background-clip: text; background-clip: text;
}
.mmx-word { font-weight: 900; font-size: clamp(2.8rem, 13vw, 6rem); line-height: 1.1;
            animation: mmx-march 3.2s linear infinite; }
.mmx[data-pat='dots'] .mmx-word {
    background-image: radial-gradient(circle, #0f766e 28%, transparent 30%); background-size: 18px 18px; }
.mmx[data-pat='waves'] .mmx-word {
    background-image: radial-gradient(circle at 50% 110%, transparent 8px, #0f766e 9px 11px, transparent 12px),
                      radial-gradient(circle at 50% -10%, transparent 8px, #14b8a6 9px 11px, transparent 12px);
    background-size: 24px 24px; }
.mmx[data-pat='checks'] .mmx-word {
    background: repeating-conic-gradient(#0f766e 0 25%, #99f6e4 0 50%) 0 0 / 24px 24px; }
.mmx-scene { font-weight: 800; font-size: 1rem;
             background: linear-gradient(100deg, #1e1b4b, #f43f5e, #f59e0b, #1e1b4b);
             background-size: 200% auto; animation: mmx-drift 9s linear infinite; }
@keyframes mmx-march { to { background-position: 24px 24px; } }
@keyframes mmx-drift { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .mmx-word, .mmx-scene { animation: none; } }
</style>
// app/Pages/Exhibition.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import MaskMedia from '@/components/MaskMedia';

export default function Exhibition() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <MaskMedia />
      </main>
    </NabuXUIProvider>
  );
}
// MaskMedia.jsx — animated media patterns running inside the glyphs
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const PATTERNS = ['dots', 'waves', 'checks'] as const;

export default function MaskMedia() {
  const [pat, setPat] = useState<'dots' | 'waves' | 'checks'>('dots');

  return (
    <>
      <style>{`
        .mmx { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
        .mmx-chips { display: inline-flex; gap: .5rem; }
        .mmx-chips button { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
                             background: transparent; cursor: pointer; font-size: .8rem; }
        .mmx-chips button[aria-pressed='true'] { border-color: #0f766e; color: #0f766e; }
        .mmx-word, .mmx-scene { margin: 0; color: transparent;
                                 -webkit-background-clip: text; background-clip: text; }
        .mmx-word { font-weight: 900; font-size: clamp(2.8rem, 13vw, 6rem); line-height: 1.1;
                    animation: mmx-march 3.2s linear infinite; }
        .mmx[data-pat='dots'] .mmx-word {
          background-image: radial-gradient(circle, #0f766e 28%, transparent 30%); background-size: 18px 18px; }
        .mmx[data-pat='waves'] .mmx-word {
          background-image: radial-gradient(circle at 50% 110%, transparent 8px, #0f766e 9px 11px, transparent 12px),
                            radial-gradient(circle at 50% -10%, transparent 8px, #14b8a6 9px 11px, transparent 12px);
          background-size: 24px 24px; }
        .mmx[data-pat='checks'] .mmx-word {
          background: repeating-conic-gradient(#0f766e 0 25%, #99f6e4 0 50%) 0 0 / 24px 24px; }
        .mmx-scene { font-weight: 800; font-size: 1rem;
                     background: linear-gradient(100deg, #1e1b4b, #f43f5e, #f59e0b, #1e1b4b);
                     background-size: 200% auto; animation: mmx-drift 9s linear infinite; }
        @keyframes mmx-march { to { background-position: 24px 24px; } }
        @keyframes mmx-drift { to { background-position: -200% center; } }
        @media (prefers-reduced-motion: reduce) { .mmx-word, .mmx-scene { animation: none; } }
      `}</style>
      <div className="mmx" data-pat={pat}>
        <div className="mmx-chips" role="group" aria-label="Pattern inside the letters">
          {PATTERNS.map((p) => (
            <button type="button" key={p} aria-pressed={pat === p} onClick={() => setPat(p)}>{p}</button>
          ))}
        </div>
        <h2 className="mmx-word" aria-label="CURRENTS">CURRENTS</h2>
        <p className="mmx-scene">Tide &amp; Stone · Rotterdam · Oct 14–18</p>
      </div>
    </>
  );
}
<!-- MaskMedia.vue — animated media patterns running inside the glyphs -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';

const patterns = ['dots', 'waves', 'checks'] as const;
const pat = ref<'dots' | 'waves' | 'checks'>('dots');
</script>

<template>
  <div class="mmx" :data-pat="pat">
    <div class="mmx-chips" role="group" aria-label="Pattern inside the letters">
      <button v-for="p in patterns" :key="p" type="button" :aria-pressed="pat === p" @click="pat = p">{{ p }}</button>
    </div>
    <h2 class="mmx-word" aria-label="CURRENTS">CURRENTS</h2>
    <p class="mmx-scene">Tide &amp; Stone · Rotterdam · Oct 14–18</p>
  </div>
</template>

<style scoped>
.mmx { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.mmx-chips { display: inline-flex; gap: .5rem; }
.mmx-chips button { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
                     background: transparent; cursor: pointer; font-size: .8rem; }
.mmx-chips button[aria-pressed='true'] { border-color: #0f766e; color: #0f766e; }
.mmx-word, .mmx-scene { margin: 0; color: transparent;
                         -webkit-background-clip: text; background-clip: text; }
.mmx-word { font-weight: 900; font-size: clamp(2.8rem, 13vw, 6rem); line-height: 1.1;
            animation: mmx-march 3.2s linear infinite; }
.mmx[data-pat='dots'] .mmx-word {
  background-image: radial-gradient(circle, #0f766e 28%, transparent 30%); background-size: 18px 18px; }
.mmx[data-pat='waves'] .mmx-word {
  background-image: radial-gradient(circle at 50% 110%, transparent 8px, #0f766e 9px 11px, transparent 12px),
                    radial-gradient(circle at 50% -10%, transparent 8px, #14b8a6 9px 11px, transparent 12px);
  background-size: 24px 24px; }
.mmx[data-pat='checks'] .mmx-word {
  background: repeating-conic-gradient(#0f766e 0 25%, #99f6e4 0 50%) 0 0 / 24px 24px; }
.mmx-scene { font-weight: 800; font-size: 1rem;
             background: linear-gradient(100deg, #1e1b4b, #f43f5e, #f59e0b, #1e1b4b);
             background-size: 200% auto; animation: mmx-drift 9s linear infinite; }
@keyframes mmx-march { to { background-position: 24px 24px; } }
@keyframes mmx-drift { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .mmx-word, .mmx-scene { animation: none; } }
</style>
<!-- MaskMedia.svelte — animated media patterns running inside the glyphs -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const patterns = ['dots', 'waves', 'checks'] as const;
  let pat = $state<'dots' | 'waves' | 'checks'>('dots');
</script>

<div class="mmx" data-pat={pat}>
  <div class="mmx-chips" role="group" aria-label="Pattern inside the letters">
    {#each patterns as p (p)}
      <button type="button" aria-pressed={pat === p} onclick={() => (pat = p)}>{p}</button>
    {/each}
  </div>
  <h2 class="mmx-word" aria-label="CURRENTS">CURRENTS</h2>
  <p class="mmx-scene">Tide &amp; Stone · Rotterdam · Oct 14–18</p>
</div>

<style>
.mmx { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.mmx-chips { display: inline-flex; gap: .5rem; }
.mmx-chips button { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
                     background: transparent; cursor: pointer; font-size: .8rem; }
.mmx-chips button[aria-pressed='true'] { border-color: #0f766e; color: #0f766e; }
.mmx-word, .mmx-scene { margin: 0; color: transparent;
                         -webkit-background-clip: text; background-clip: text; }
.mmx-word { font-weight: 900; font-size: clamp(2.8rem, 13vw, 6rem); line-height: 1.1;
            animation: mmx-march 3.2s linear infinite; }
.mmx[data-pat='dots'] .mmx-word {
  background-image: radial-gradient(circle, #0f766e 28%, transparent 30%); background-size: 18px 18px; }
.mmx[data-pat='waves'] .mmx-word {
  background-image: radial-gradient(circle at 50% 110%, transparent 8px, #0f766e 9px 11px, transparent 12px),
                    radial-gradient(circle at 50% -10%, transparent 8px, #14b8a6 9px 11px, transparent 12px);
  background-size: 24px 24px; }
.mmx[data-pat='checks'] .mmx-word {
  background: repeating-conic-gradient(#0f766e 0 25%, #99f6e4 0 50%) 0 0 / 24px 24px; }
.mmx-scene { font-weight: 800; font-size: 1rem;
             background: linear-gradient(100deg, #1e1b4b, #f43f5e, #f59e0b, #1e1b4b);
             background-size: 200% auto; animation: mmx-drift 9s linear infinite; }
@keyframes mmx-march { to { background-position: 24px 24px; } }
@keyframes mmx-drift { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .mmx-word, .mmx-scene { animation: none; } }
</style>