Ripple
An orb for an assistant's states: a ball of 1-bit dots whose surface moves like cloth; creases chase across it while it thinks.
Installation
Terminal
npx shadcn@latest add https://fabrickit.org/r/ripple.jsonTerminal
pnpm dlx shadcn@latest add https://fabrickit.org/r/ripple.jsonTerminal
yarn shadcn@latest add https://fabrickit.org/r/ripple.jsonTerminal
bunx --bun shadcn@latest add https://fabrickit.org/r/ripple.jsonThis copies the component into components/fabricui and its engine into lib/fabricui. It's your code from then on. First time? Add the theme once: see Installation.
Step 1: Add the theme (once)
Every colour, radius and curve the components use, as --fabric-* variables. Save it as fabric.css next to your global CSS and import it there. If you've added another Fabric Kit component before, skip this.globals.css@import "./fabric.css";fabric.css/* * fabric.css — Fabric Kit's theme: every colour, radius, ring and curve the * components use, as --fabric-* variables (prefixed, so they never clash * with your own shadcn theme). Installed by `shadcn add @fabrickit/theme` * (it lands in your global CSS) — or import this file once, globally. * Dark by default. For light, put data-theme="light" on <html> (or on any * element: the tokens follow it down the tree; data-theme="dark" turns back). */ :root, [data-theme="dark"] { --fabric-page: #111111; --fabric-surface: #191919; /* triggers, recessed tiles */ --fabric-panel: #202020; /* open panels */ --fabric-raised: #2a2a2a; /* hover, range band */ --fabric-raised-hi: #343434; /* hover inside a band */ --fabric-preview: #252525; /* soft preview fills */ --fabric-text: #e0e0e0;Step 2: Copy the shared engines
Plain JavaScript that does the motion, shared between components. Create each file at the same path in your project; if a file is already there from another component, keep it.lib/fabricui/mount.js/* * mount.js — runs a Fabric Kit engine for a React component and cleans up * after it. The engines are plain JavaScript that wire themselves to the page * (listeners on the document, resize observers, a few elements of their own); * mount() records everything an engine attaches and changes while it's being * set up, and dispose() takes it all back, so a component can come and go (or * be set up twice in a row, as React's Strict Mode does) without leaving * anything behind. * * const m = mount(() => new Engine(root, options)); * m.instance; // the engine * m.dispose(); // on unmount: listeners and observers off, the DOM as it was, then instance.destroy() * // (and destroy() on anything it owns that registered itself, like each ClothDrop) */ export function mount(create) { const ac = new AbortController();Step 3: Copy the Ripple files
The component itself. Create each one at the same path in your project. It's your code from here on.components/fabricui/ripple.tsx"use client"; import * as React from "react"; import { mount } from "@/lib/fabricui/mount"; import { Ripple as RippleEngine } from "@/lib/fabricui/ripple-engine"; import "./ripple.css"; const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect; export type RippleState = "idle" | "listening" | "thinking" | "searching" | "speaking" | "done" | "error"; const SAYS: Record<RippleState, string> = { idle: "Ready", listening: "Listening", thinking: "Thinking", searching: "Searching", speaking: "Speaking", done: "Done", error: "Something went wrong", };components/fabricui/ripple.css/* * ripple.css — Ripple (ripple-engine.js). The ball is drawn on its canvas in the * element's text colour; set `color` on it (or a parent) to tint it. */ .ripple:where(.fui-ripple, .fui-ripple *) { display: inline-block; flex: none; vertical-align: middle; color: var(--fabric-text); } .ripple > canvas:where(.fui-ripple, .fui-ripple *) { display: block; } /* light: a soft grey ink rather than black */ [data-theme="light"] .ripple:where(.fui-ripple, .fui-ripple *) { color: #737373; } /* a step under the moon's: its dots are sparser and smaller, so this reads the same */lib/fabricui/ripple-engine.js/* * ripple-engine.js — Ripple (ripple.css). An orb for showing what an assistant * is doing: a ball of 1-bit dots whose surface moves like cloth. A crease runs * across it: the dots bunch into the fold and spread out behind it, and the * fold catches the light on one side and falls into shadow on the other. Every * dot is the same small round dot, on or off; the light is how many are on, * through an 8×8 ordered pattern laid over the surface. Drawn on a 2D canvas * (no WebGL), so a page can hold many. * * const r = new Ripple(rootEl, { state: "thinking", size: 64 }); * r.set({ state: "done" }); * * idle one slow, soft crease drifting across * listening fine ripples run over it with the voice (`level`, 0–1; made up if not given) * thinking creases chase each other across the ball * searching one sharp crease sweeps back and forthStep 4: Check the import paths
The files import each other through the @/ alias (the shadcn default, there in a new Next.js app). If your project doesn't have it, add it to tsconfig.json, or change the imports to relative paths.tsconfig.json{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./*"] } } }Step 5: Use it
Import it from @/components/fabricui/ripple. The Usage example below shows it in a page.
Code
components/fabricui/ripple.tsx
"use client";
import * as React from "react";
import { mount } from "@/lib/fabricui/mount";
import { Ripple as RippleEngine } from "@/lib/fabricui/ripple-engine";
import "./ripple.css";
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
export type RippleState = "idle" | "listening" | "thinking" | "searching" | "speaking" | "done" | "error";
const SAYS: Record<RippleState, string> = {
idle: "Ready", listening: "Listening", thinking: "Thinking", searching: "Searching",
speaking: "Speaking", done: "Done", error: "Something went wrong",
};
components/fabricui/ripple.css
/*
* ripple.css — Ripple (ripple-engine.js). The ball is drawn on its canvas in the
* element's text colour; set `color` on it (or a parent) to tint it.
*/
.ripple:where(.fui-ripple, .fui-ripple *) {
display: inline-block;
flex: none;
vertical-align: middle;
color: var(--fabric-text);
}
.ripple > canvas:where(.fui-ripple, .fui-ripple *) { display: block; }
/* light: a soft grey ink rather than black */
[data-theme="light"] .ripple:where(.fui-ripple, .fui-ripple *) { color: #737373; } /* a step under the moon's: its dots are sparser and smaller, so this reads the same */
lib/fabricui/ripple-engine.js
/*
* ripple-engine.js — Ripple (ripple.css). An orb for showing what an assistant
* is doing: a ball of 1-bit dots whose surface moves like cloth. A crease runs
* across it: the dots bunch into the fold and spread out behind it, and the
* fold catches the light on one side and falls into shadow on the other. Every
* dot is the same small round dot, on or off; the light is how many are on,
* through an 8×8 ordered pattern laid over the surface. Drawn on a 2D canvas
* (no WebGL), so a page can hold many.
*
* const r = new Ripple(rootEl, { state: "thinking", size: 64 });
* r.set({ state: "done" });
*
* idle one slow, soft crease drifting across
* listening fine ripples run over it with the voice (`level`, 0–1; made up if not given)
* thinking creases chase each other across the ball
* searching one sharp crease sweeps back and forthUsage
Usage
"use client";
import { Ripple } from "@/components/fabricui/ripple";
export function Assistant({ busy, failed }: { busy: boolean; failed: boolean }) {
return <Ripple state={failed ? "error" : busy ? "thinking" : "done"} size={64} />;
}
// beside a line of text
export function Status() {
return <p><Ripple state="searching" size={20} /> Searching the docs…</p>;
}Props
| Prop | Type | Default |
|---|---|---|
| state What the assistant is doing (error turns it red). Changes blend; they never cut. | "idle" | "listening" | "thinking" | "searching" | "speaking" | "done" | "error" | "thinking" |
| size px. Tuned for 20 (beside text) and 64 (an avatar); other sizes use the nearer tuning. | number | 64 |
| speed Animation speed. | number | 1 |
| paused Hold it still. | boolean | false |
| level Listening: the voice level, 0–1, from your audio. Left out, it makes one up. | number | — |
| label What screen readers hear. Default: the state in words ("Thinking"). | string | — |