Timace

Text reveal

components/ui/text-reveal.tsx
export interface TextRevealProps {
  text: string;
  as?: "h1" | "h2" | "h3" | "p";
  className?: string;
}

/**
 * A line that arrives a word at a time: each word rises out of its own
 * baseline and comes into focus, one after the next. Give it a new `key` to
 * play it again.
 */
export function TextReveal({ text, as: Tag = "h2", className }: TextRevealProps) {
  const words = text.split(/\s+/).filter(Boolean);
  return (
    <Tag
      data-slot="text-reveal"
      aria-label={text}
      className={["m-0 font-(family-name:--tui-font) text-(length:--tui-text-reveal-size) leading-(--tui-text-reveal-leading) font-(--tui-text-reveal-weight) tracking-[-0.02em] text-(--tui-text-reveal-fg)", className].filter(Boolean).join(" ")}
    >
      {words.map((word, i) => (
        <span key={i} aria-hidden className="mr-[0.25em] inline-block overflow-hidden pb-[0.12em] align-bottom last:mr-0">
          <span className="inline-block [animation:tui-rise_var(--tui-text-reveal-duration)_cubic-bezier(0.2,0.7,0.2,1)_both] motion-reduce:[animation:none]" style={{ animationDelay: `calc(var(--tui-text-reveal-stagger) * ${i})` }}>
            {word}
          </span>
        </span>
      ))}
    </Tag>
  );
}
styles/timace-ui.css
:root {
  color-scheme: light;
  --tui-bg: #ffffff;
  --tui-fg: #0a0a0a;
  --tui-muted: #f5f5f5;
  --tui-muted-fg: #737373;
  --tui-border: #e5e5e5;
  --tui-primary: #171717;
  --tui-primary-fg: #fafafa;
  --tui-ring: #a3a3a3;
  --tui-success: #16a34a;
  --tui-warning: #d97706;
  --tui-danger: #dc2626;
  --tui-radius: 8px;
  --tui-border-width: 1px;
  --tui-space: 4px;
  --tui-shadow: none;
  --tui-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --tui-text: 14px;
  --tui-duration: 150ms;

  /* Text reveal */
  --tui-text-reveal-duration: 0.8s;
  --tui-text-reveal-stagger: 80ms;
  --tui-text-reveal-blur: 8px;
  --tui-text-reveal-size: 44px;
  --tui-text-reveal-weight: 600;
  --tui-text-reveal-leading: 1.1;
  --tui-text-reveal-fg: var(--tui-fg);
}

.dark,
[data-theme="dark"] {
  color-scheme: dark;
  --tui-bg: #0a0a0a;
  --tui-fg: #fafafa;
  --tui-muted: #1c1c1c;
  --tui-muted-fg: #a3a3a3;
  --tui-border: #2a2a2a;
  --tui-primary: #fafafa;
  --tui-primary-fg: #171717;
  --tui-ring: #737373;
  --tui-success: #22c55e;
  --tui-warning: #f59e0b;
  --tui-danger: #ef4444;
}

@keyframes tui-rise {
  from { transform: translateY(110%); opacity: 0; filter: blur(var(--tui-text-reveal-blur)); }
  to { transform: none; opacity: 1; filter: blur(0); }
}

Needs Tailwind CSS v4. Import the stylesheet once, after Tailwind.