Skip to content
Components

Split Text

Split Text brings controlled expression to your interface.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/split-text.json

Use it

Scroll horizontally for long lines
"use client";
import {SplitText} from '@/components/jez-ui/ui/split-text';

export default function Example(){

return <><div className="w-full rounded-xl bg-foreground px-7 py-14 text-background md:px-12 md:py-20"><SplitText className="block font-display text-5xl font-medium leading-none tracking-tight md:text-7xl">Stay curious.</SplitText><p className="mt-8 text-sm opacity-70">Good ideas start with a little movement.</p></div></>;
}

Props & types

Scroll horizontally for long lines
{
  children: string;
  className?: string;
}

Source

View 2 source files

registry/ui/split-text.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { motion, useReducedMotion } from "motion/react";
export function SplitText({
  children,
  className,
}: {
  children: string;
  className?: string;
}) {
  const reduce = useReducedMotion();
  return (
    <span aria-label={children} className={cn("inline-block", className)}>
      {children.split(" ").map((word, i) => (
        <motion.span
          aria-hidden="true"
          key={i}
          className="mr-[.25em] inline-block"
          initial={reduce ? false : { y: 18, filter: "blur(5px)" }}
          whileInView={{ y: 0, filter: "blur(0px)" }}
          viewport={{ once: true }}
          transition={{ delay: i * 0.055, duration: 0.55 }}
        >
          {word}
        </motion.span>
      ))}
    </span>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

Dependencies

motion@13.2.0 · clsx@2.1.1 · tailwind-merge@3.5.0

Accessibility & behaviour

Respect reduced-motion preferences. Decorative effects must not carry essential information. WebGL scenes include a static fallback and only render while visible.

Read the accessibility and performance guide →