Micro FX JS behaviour

Ripple click

The advanced Material ripple: a circle born at the exact press point in the theme colour, sized to the farthest corner, then grown and faded — on a button, a card and tabs; it answers pointerdown and keyboard alike (Enter/Space from centre) with the radius measured from each surface’s real geometry.

Documentation

Real scenarios

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

A ripple that knows where you pressed

Every surface here — the card, both buttons and each tab — spawns its ripple from the exact pointerdown coordinates, sized to twice the farthest corner so it always sweeps the whole surface before fading. The ink is currentColor, so the filled button ripples light and the tabs ripple in the theme colour; Enter and Space drop it from the centre. One AbortController wires every listener and unwires them all at once.

Atlas Studio — Q3 invoice

€4,200

3 projects · 18 invoices · average turnaround 2.4 days. The card itself is a ripple surface — press it anywhere.

PDF export run by Lena Ortiz, 4 minutes ago. Next scheduled export: Friday 18:00 UTC.

Atlas Studio BV · Prinsengracht 1, Amsterdam · VAT NL8612… · Net 14 terms.

Important props

Important props
Prop Type Default What it does
origin event 'pointer · center' The ripple boils from the exact pointerdown coordinates; the keyboard (Enter/Space) drops it from the surface’s centre.
radius geometry '2 × farthest corner + 8px' The radius is the farthest corner from the press point, doubled — no ripple ever dies half-way.
ink color 'currentColor' The ripple ink is the surface’s text colour; light on the filled button, theme colour on the tabs.
duration ms '550' It grows on Material’s official curve (cubic-bezier(.2,0,0,1)) and fades away.
prefers-reduced-motion behaviour 'skip' No ripple is spawned; selection and tab states still switch instantly.

Snippet

{{-- rippleClick(): every [data-ripple] is a surface; the ripple boils
     from the exact press point, sized to the farthest corner. --}}
<div class="mfrp" x-data="rippleClick()">
<article class="mfrp-card mfrp-surf" data-ripple>
<h3>Atlas Studio invoice</h3>
<div class="mfrp-tabs" role="tablist">
<button role="tab" data-ripple x-on:click="tab = 'overview'">Overview</button>
<button role="tab" data-ripple x-on:click="tab = 'activity'">Activity</button>
<button role="tab" data-ripple x-on:click="tab = 'billing'">Billing</button>
</div>
<p x-show="tab === 'overview'">3 projects · 18 invoices · €4,200 total</p>
<footer>
<button class="mfrp-primary" data-ripple>Download PDF</button>
<button class="mfrp-ghost" data-ripple>Share</button>
</footer>
</article>
<p class="mfrp-hint" x-text="last"></p>
</div>

<style>
.mfrp-surf { position: relative; overflow: clip; }
.mfrp-ink { position: absolute; border-radius: 50%; background: currentColor;
            translate: -50% -50%; pointer-events: none;
            animation: mfrp-grow .55s cubic-bezier(.2, 0, 0, 1) forwards; }
@keyframes mfrp-grow { from { scale: 0; opacity: .3; } to { scale: 1; opacity: 0; } }
.mfrp-primary { block-size: 40px; padding-inline: 18px; border: none; border-radius: 999px;
                background: #4f46e5; color: #fff; cursor: pointer; }
</style>
// app/Pages/Invoices.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 RippleCard from '@/components/RippleCard';

export default function Invoices() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <RippleCard />
      </main>
    </NabuXUIProvider>
  );
}
// RippleCard.jsx — the ripple that answers pointer and keyboard alike
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';

const TABS = [
  { id: 'overview', label: 'Overview', body: '3 projects · 18 invoices · €4,200 total' },
  { id: 'activity', label: 'Activity', body: 'PDF export run by Lena, 4 min ago' },
  { id: 'billing', label: 'Billing', body: 'Atlas Studio · Prinsengracht 1, Amsterdam' },
];

export default function RippleCard() {
  const rootRef = useRef(null);
  const [tab, setTab] = useState('overview');

  // One AbortController wires — and later unwires — every surface.
  useEffect(() => {
    const root = rootRef.current;
    const ac = new AbortController();
    const mq = matchMedia('(prefers-reduced-motion: reduce)');

    const spawn = (el, cx, cy) => {
      if (mq.matches) return;
      const r = el.getBoundingClientRect();
      const x = cx - r.left, y = cy - r.top;
      const far = Math.max(
        Math.hypot(x, y), Math.hypot(r.width - x, y),
        Math.hypot(x, r.height - y), Math.hypot(r.width - x, r.height - y));
      const size = Math.ceil(far * 2 + 8);
      const ink = document.createElement('span');
      ink.className = 'mfrp-ink';
      ink.style.width = ink.style.height = size + 'px';
      ink.style.left = x + 'px';
      ink.style.top = y + 'px';
      ink.addEventListener('animationend', () => ink.remove(), { signal: ac.signal });
      el.appendChild(ink);
    };

    root.querySelectorAll('[data-ripple]').forEach((el) => {
      el.addEventListener('pointerdown', (e) => spawn(el, e.clientX, e.clientY), { signal: ac.signal });
      el.addEventListener('keydown', (e) => {
        if (e.key !== 'Enter' && e.key !== ' ') return;
        const r = el.getBoundingClientRect();
        spawn(el, r.left + r.width / 2, r.top + r.height / 2);
      }, { signal: ac.signal });
    });
    return () => ac.abort();
  }, []);

  return (
    <>
      <style>{`
        .mfrp-card { position: relative; overflow: clip; max-inline-size: 26rem; padding: 1.4rem;
                     border-radius: 1rem; border: 1px solid #e7e5e4; background: #fff; }
        .mfrp-surf { position: relative; overflow: clip; }
        .mfrp-ink { position: absolute; border-radius: 50%; background: currentColor;
                    translate: -50% -50%; pointer-events: none;
                    animation: mfrp-grow .55s cubic-bezier(.2, 0, 0, 1) forwards; }
        @keyframes mfrp-grow { from { scale: 0; opacity: .3; } to { scale: 1; opacity: 0; } }
        .mfrp-tabs { display: inline-flex; gap: .25rem; margin-block: 1rem; }
        .mfrp-tabs button { position: relative; overflow: clip; padding: .5rem .9rem; border: none;
                            border-radius: 999px; background: transparent; cursor: pointer; }
        .mfrp-tabs button[aria-selected='true'] { background: #4f46e5; color: #fff; }
        .mfrp-primary { block-size: 40px; padding-inline: 18px; border: none; border-radius: 999px;
                        background: #4f46e5; color: #fff; cursor: pointer; }
        .mfrp-ghost { block-size: 40px; padding-inline: 18px; border-radius: 999px; border: 1px solid #e7e5e4;
                      background: transparent; cursor: pointer; }
      `}</style>
      <article ref={rootRef} className="mfrp-card mfrp-surf" data-ripple>
        <h3>Atlas Studio invoice</h3>
        <div className="mfrp-tabs" role="tablist">
          {TABS.map((t) => (
            <button key={t.id} role="tab" data-ripple aria-selected={tab === t.id}
              onClick={() => setTab(t.id)}>{t.label}</button>
          ))}
        </div>
        <p>{TABS.find((t) => t.id === tab).body}</p>
        <footer>
          <button className="mfrp-primary" data-ripple>Download PDF</button>{' '}
          <button className="mfrp-ghost" data-ripple>Share</button>
        </footer>
      </article>
    </>
  );
}
<!-- RippleCard.vue — the ripple that answers pointer and keyboard alike -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';

const TABS = [
  { id: 'overview', label: 'Overview', body: '3 projects · 18 invoices · €4,200 total' },
  { id: 'activity', label: 'Activity', body: 'PDF export run by Lena, 4 min ago' },
  { id: 'billing', label: 'Billing', body: 'Atlas Studio · Prinsengracht 1, Amsterdam' },
];
const root = ref<HTMLElement | null>(null);
const tab = ref('overview');
let ac: AbortController | null = null;

onMounted(() => {
  ac = new AbortController();
  const mq = matchMedia('(prefers-reduced-motion: reduce)');
  const spawn = (el: Element, cx: number, cy: number) => {
    if (mq.matches) return;
    const r = el.getBoundingClientRect();
    const x = cx - r.left, y = cy - r.top;
    const far = Math.max(
      Math.hypot(x, y), Math.hypot(r.width - x, y),
      Math.hypot(x, r.height - y), Math.hypot(r.width - x, r.height - y));
    const size = Math.ceil(far * 2 + 8);
    const ink = document.createElement('span');
    ink.className = 'mfrp-ink';
    (ink.style as any).width = (ink.style as any).height = size + 'px';
    ink.style.left = x + 'px';
    ink.style.top = y + 'px';
    ink.addEventListener('animationend', () => ink.remove(), { signal: ac!.signal });
    el.appendChild(ink);
  };
  root.value!.querySelectorAll('[data-ripple]').forEach((el) => {
    el.addEventListener('pointerdown', (e: PointerEvent) => spawn(el, e.clientX, e.clientY), { signal: ac!.signal });
    el.addEventListener('keydown', (e: KeyboardEvent) => {
      if (e.key !== 'Enter' && e.key !== ' ') return;
      const r = el.getBoundingClientRect();
      spawn(el, r.left + r.width / 2, r.top + r.height / 2);
    }, { signal: ac!.signal });
  });
});
onBeforeUnmount(() => ac?.abort());
</script>

<template>
  <article ref="root" class="mfrp-card mfrp-surf" data-ripple>
    <h3>Atlas Studio invoice</h3>
    <div class="mfrp-tabs" role="tablist">
      <button v-for="t in TABS" :key="t.id" role="tab" data-ripple
        :aria-selected="tab === t.id" @click="tab = t.id">{{ t.label }}</button>
    </div>
    <p>{{ TABS.find((t) => t.id === tab)!.body }}</p>
    <footer>
      <button class="mfrp-primary" data-ripple>Download PDF</button>
      <button class="mfrp-ghost" data-ripple>Share</button>
    </footer>
  </article>
</template>

<style scoped>
.mfrp-card { position: relative; overflow: clip; max-inline-size: 26rem; padding: 1.4rem;
             border-radius: 1rem; border: 1px solid #e7e5e4; background: #fff; }
.mfrp-surf { position: relative; overflow: clip; }
.mfrp-ink { position: absolute; border-radius: 50%; background: currentColor;
            translate: -50% -50%; pointer-events: none;
            animation: mfrp-grow .55s cubic-bezier(.2, 0, 0, 1) forwards; }
@keyframes mfrp-grow { from { scale: 0; opacity: .3; } to { scale: 1; opacity: 0; } }
.mfrp-tabs { display: inline-flex; gap: .25rem; margin-block: 1rem; }
.mfrp-tabs button { position: relative; overflow: clip; padding: .5rem .9rem; border: none;
                    border-radius: 999px; background: transparent; cursor: pointer; }
.mfrp-tabs button[aria-selected='true'] { background: #4f46e5; color: #fff; }
.mfrp-primary { block-size: 40px; padding-inline: 18px; border: none; border-radius: 999px;
                background: #4f46e5; color: #fff; cursor: pointer; }
.mfrp-ghost { block-size: 40px; padding-inline: 18px; border-radius: 999px; border: 1px solid #e7e5e4;
              background: transparent; cursor: pointer; }
</style>
<!-- RippleCard.svelte — the ripple that answers pointer and keyboard alike -->
<script lang="ts">
  import { onMount } from 'svelte';
  import '@nabuxai/ui-core/css';

  const TABS = [
    { id: 'overview', label: 'Overview', body: '3 projects · 18 invoices · €4,200 total' },
    { id: 'activity', label: 'Activity', body: 'PDF export run by Lena, 4 min ago' },
    { id: 'billing', label: 'Billing', body: 'Atlas Studio · Prinsengracht 1, Amsterdam' },
  ];
  let root: HTMLElement;
  let tab = $state('overview');

  onMount(() => {
    const ac = new AbortController();
    const mq = matchMedia('(prefers-reduced-motion: reduce)');
    const spawn = (el: Element, cx: number, cy: number) => {
      if (mq.matches) return;
      const r = el.getBoundingClientRect();
      const x = cx - r.left, y = cy - r.top;
      const far = Math.max(
        Math.hypot(x, y), Math.hypot(r.width - x, y),
        Math.hypot(x, r.height - y), Math.hypot(r.width - x, r.height - y));
      const size = Math.ceil(far * 2 + 8);
      const ink = document.createElement('span');
      ink.className = 'mfrp-ink';
      ink.style.width = ink.style.height = size + 'px';
      ink.style.left = x + 'px';
      ink.style.top = y + 'px';
      ink.addEventListener('animationend', () => ink.remove(), { signal: ac.signal });
      el.appendChild(ink);
    };
    root.querySelectorAll('[data-ripple]').forEach((el) => {
      el.addEventListener('pointerdown', (e: PointerEvent) => spawn(el, e.clientX, e.clientY), { signal: ac.signal });
      el.addEventListener('keydown', (e: KeyboardEvent) => {
        if (e.key !== 'Enter' && e.key !== ' ') return;
        const r = el.getBoundingClientRect();
        spawn(el, r.left + r.width / 2, r.top + r.height / 2);
      }, { signal: ac.signal });
    });
    return () => ac.abort();
  });
</script>

<article bind:this={root} class="mfrp-card mfrp-surf" data-ripple>
  <h3>Atlas Studio invoice</h3>
  <div class="mfrp-tabs" role="tablist">
    {#each TABS as t (t.id)}
      <button role="tab" data-ripple aria-selected={tab === t.id} onclick={() => (tab = t.id)}>
        {t.label}
      </button>
    {/each}
  </div>
  <p>{TABS.find((t) => t.id === tab)!.body}</p>
  <footer>
    <button class="mfrp-primary" data-ripple>Download PDF</button>
    <button class="mfrp-ghost" data-ripple>Share</button>
  </footer>
</article>

<style>
.mfrp-card { position: relative; overflow: clip; max-inline-size: 26rem; padding: 1.4rem;
             border-radius: 1rem; border: 1px solid #e7e5e4; background: #fff; }
.mfrp-surf { position: relative; overflow: clip; }
.mfrp-ink { position: absolute; border-radius: 50%; background: currentColor;
            translate: -50% -50%; pointer-events: none;
            animation: mfrp-grow .55s cubic-bezier(.2, 0, 0, 1) forwards; }
@keyframes mfrp-grow { from { scale: 0; opacity: .3; } to { scale: 1; opacity: 0; } }
.mfrp-tabs { display: inline-flex; gap: .25rem; margin-block: 1rem; }
.mfrp-tabs button { position: relative; overflow: clip; padding: .5rem .9rem; border: none;
                    border-radius: 999px; background: transparent; cursor: pointer; }
.mfrp-tabs button[aria-selected='true'] { background: #4f46e5; color: #fff; }
.mfrp-primary { block-size: 40px; padding-inline: 18px; border: none; border-radius: 999px;
                background: #4f46e5; color: #fff; cursor: pointer; }
.mfrp-ghost { block-size: 40px; padding-inline: 18px; border-radius: 999px; border: 1px solid #e7e5e4;
              background: transparent; cursor: pointer; }
</style>