Skip to main content

Blur Swap Text

Cycles words or phrases inside a sentence with a vertical blur swap and a smooth width transition on a single slot wrapper.

Build interfaces that feel smoother

Customize

Interval (ms)2400
Blur (px)8
Distance (px)14

Installation

Add the component with the registry command:

npx shadcn@latest add @kinetic/blur-swap-text

Usage

Place BlurSwapText inline inside a heading or sentence and pass the list of phrases to cycle through:

import { BlurSwapText } from "@/components/kinetic/ui/blur-swap-text";

export function HeroHeadline() {
  return (
    <h1 className="text-3xl font-semibold tracking-tight">
      Build interfaces that feel{" "}
      <BlurSwapText words={["crisp", "responsive", "effortless"]} />.
    </h1>
  );
}

Trigger and playback

Control when cycling starts with trigger ("mount", "inView", or "manual"), adjust the pause between swaps with intervalMs, or set autoPlay={false} to step manually. The auto-swap loop automatically pauses when the element leaves the viewport or when the browser tab becomes hidden.

<BlurSwapText
  words={["design", "engineering", "motion"]}
  trigger="inView"
  intervalMs={3000}
  blurPx={6}
  distancePx={12}
/>

Imperative controls

Attach a ref typed with BlurSwapTextHandle to trigger play(), reverse(), next(), or prev() from external controls:

import { useRef } from "react";
import { BlurSwapText, type BlurSwapTextHandle } from "@/components/kinetic/ui/blur-swap-text";

interface PhraseStepperProps {
  readonly phrases: readonly string[];
}

export function PhraseStepper({ phrases }: PhraseStepperProps) {
  const swapRef = useRef<BlurSwapTextHandle>(null);

  return (
    <div className="flex items-center gap-3">
      <BlurSwapText ref={swapRef} words={phrases} autoPlay={false} trigger="manual" />
      <button type="button" onClick={() => swapRef.current?.prev()}>
        Previous
      </button>
      <button type="button" onClick={() => swapRef.current?.next()}>
        Next
      </button>
    </div>
  );
}

Motion preferences

BlurSwapText respects both the system prefers-reduced-motion setting and Kinetic's data-reduced-motion attribute. Under reduced motion, automatic cycling, blur, vertical slide, and width transitions are disabled; imperative steps update the phrase immediately. All timing scales with data-tempo and the speed prop.

API Reference

BlurSwapText

Inline phrase swapper with single-element width transition and automatic visibility pausing.

PropTypeDefaultDescription
wordsreadonly string[]-Phrases to cycle through.
intervalMsnumber2400Auto-swap interval in milliseconds.
autoPlaybooleantrueWhether to cycle automatically while visible.
blurPxnumber8Blur radius during swap (max 8px).
trigger"mount" | "inView" | "manual""mount"Activation trigger mode.
speednumber1Speed multiplier.