Skip to main content

Focus Text

Camera rack-focus text entrance on a single element that sharpens from heavy blur, slight scale, and wide tracking into its resting style.

In focus

Customize

Blur (px)16
Duration (ms)900

Installation

npx shadcn@latest add @kinetic/focus-text

Usage

Render FocusText with a text string and an optional semantic as tag. The entire string animates on a single element without splitting into characters or words.

import { FocusText } from "@/components/kinetic/ui/focus-text";

export function HeroHeadline() {
  return (
    <FocusText
      as="h1"
      text="Sharp focus on arrival"
      className="text-3xl font-semibold tracking-tight"
    />
  );
}

Triggers and imperative control

Use trigger with mount, inView, or manual. Attach a ref typed with FocusTextHandle to call play() to focus in or reverse() to blur back out faster.

import { useRef } from "react";
import { FocusText, type FocusTextHandle } from "@/components/kinetic/ui/focus-text";

interface FocusDemoProps {
  readonly label: string;
}

export function FocusDemo({ label }: FocusDemoProps) {
  const focusRef = useRef<FocusTextHandle>(null);

  return (
    <div className="space-y-3">
      <FocusText ref={focusRef} text={label} trigger="manual" />
      <div className="flex gap-2">
        <button type="button" onClick={() => focusRef.current?.play()}>
          Focus in
        </button>
        <button type="button" onClick={() => focusRef.current?.reverse()}>
          Blur out
        </button>
      </div>
    </div>
  );
}

Blur and timing

Tune the starting blur radius with blurPx (default 16, clamped to 24) and set durationMs (default 900) or speed (default 1). Reversing runs at 0.55x the forward duration so exits feel crisp.

<FocusText text="Soft optical pull" blurPx={20} durationMs={1100} speed={1.2} />

Motion preferences

FocusText reads the global tempo scale and reduced-motion preference automatically. When reduced motion is enabled, it renders sharp immediately with no blur or scale animation and invokes onComplete.

API Reference

FocusText

Single-element rack-focus text component without DOM splitting.

PropTypeDefaultDescription
textstring-Headline or phrase to focus.
blurPxnumber16Starting blur radius (max 24px).
durationMsnumber900Focus-in duration in milliseconds.
trigger"mount" | "inView" | "manual""mount"Activation trigger mode.
speednumber1Speed multiplier.