Docs
β†’
Vertical Cut Reveal

Vertical Cut Reveal

A text component that reveals the text with a cut reveal effect.

HI πŸ‘‹, FRIEND!🌀️ IT IS NICE β‡— TOMEET 😊 YOU.

Source code


Understanding the component


  1. First, the text is split into smaller pieces based on the splitBy prop:

    • words: Splits into individual words (e.g., "Hello world" β†’ ["Hello", "world"])
    • characters: Splits into individual characters (e.g., "Hi" β†’ ["H", "i"])
    • lines: Splits by newline characters (\n)
    • string: Splits by any custom string delimiter
  2. Each piece of text is wrapped in two <span> elements:

    • An outer <span> that acts as a container with its position to prelative and its overflow to overflow-hidden
    • An inner <span> that holds the actual text, initially positioned off-screen using y: 100 (or -100 if reverse is true)
  3. When the animation starts:

    • The inner <span> elements smoothly transition from their off-screen position (y: 100) to their final position (y: 0)
    • This creates a "cutting" or "revealing" effect as each piece of text slides into view
    • The animation can be staggered from different directions (first, last, center, or random) using the staggerFrom prop

A key implementation detail is that the component always maintains word boundaries, even when splitting by characters. There are two reason for this:

  1. When dealing with multi-line text, each line maintains its own reveal animation starting point. This means if you have text that spans multiple lines, each line will animate independently from its own baseline, rather than all elements animating from a single point (like the bottom of the entire paragraph).
  2. When using characters mode, characters from the same word stay together in a word container. This prevents unwanted line breaks in the middle of words - if a word needs to wrap to the next line, it will wrap as a complete unit rather than having some characters on one line and others on the next line. This maintains proper text flow and readability while still allowing character-by-character animation within each word.

Examples


splitBy variations

With the splitBy prop, you can control how the text is split into smaller pieces. It can be either words, characters, lines, or a custom string delimiter.

β†’ We're on a mission to make the 🌐 web super fun again! ☺
super cool & awesome example text

staggerFrom variations

With the staggerFrom prop, you can control the starting index of the animation. It can be either first, last, center, a number (custom index).

THIS STAGGERS FROM FIRSTTHIS STAGGERS FROM LASTTHIS STAGGERS FROM CENTERTHIS ONE FROM THE 5TH CHARACTER

Or you can use the random option, which will animate the elements in a random order. You can see the multiline text in action here too:

β€œWhen a small, unassuming object exceeds our expectations, we are not only surprised but pleased. Our usual reaction is something like, "That little thing did all that?" Simplicity is about the unexpected pleasure derived from what is likely to be insignificant and would otherwise go unnoticed. The smaller the object, the more forgiving we can be when it misbehaves.” ― John Maeda,

No auto start

If you don't want the animation to start automatically, you can set the autoStart prop to false. In this case, you can call the startAnimation method exposed via a ref to start the animation manually. Here is an example demonstrating how to do this when the component is inside the viewport (with the useInView hook from framer motion):

Scroll down champ ↓
howdy! πŸ‘‹

Notes


Since each element is "cutted" because of the overflow-hidden property, with some fonts and font-families (eg italic), parts of the letter may be cutoff. That's why you can use the containerClassName prop to style the container element, the worldLeterLevelClassName prop to style word level container, and the elementLevelClassName prop to style the individual split elements. You can add padding for example to accomodate more space for the text.

Props


PropTypeDefaultDescription
children*string-The text to be displayed and animated
reversebooleantrueDirection of the animation (true: bottom to top, false: top to bottom)
transitionDynamicAnimationOptions{ type: "spring", damping: 30, stiffness: 300 }Animation configuration for each element. Refer to framer-motion docs for more details
splitBy"words" | "characters" | "lines" | string"words"The split method for the text
staggerDurationnumber0.2Delay between each element's animation start
staggerFrom"first" | "last" | "center" | "random" | number"first"Starting index of the animation
containerClassNamestring-Additional CSS classes for styling the container
wordLevelClassNamestring-Additional CSS classes for styling the word level container
elementLevelClassNamestring-Additional CSS classes for styling the individual elements
onClick() => void-Callback function for click events
onStart() => void-Callback function for when the animation starts
onComplete() => void-Callback function for when the animation completes
autoStartbooleantrueWhether to start the animation automatically