Search

Back

Copy Link

Library

/

Free

/

106

Type Out Text

106

Type Out Text

Any message is typed out when the layer is in view of the user.

Not loading? Preview

Made by

@frameroverrides

override

appear

Override

Type Out Text

Copy

Override

Copied to Clipboard!

Instructions

Apply to any text layer

Control the speed of the typing under speed in the code. Raising this number will slower the typing.

Code Preview

import type { ComponentType } from "react"
import { useRef, useEffect, useState } from "react"
import { useInView } from "framer-motion"

const message =
        "FramerOverrides is the largest library of overrides & components for Framer",

speed = 30 // raise this number to type slower

export function withTypeOut(Component): ComponentType {
    return (props) => {
        const ref = useRef(null)
        const isInView = useInView(ref)
        const [part, setPart] = useState("")
        const [index, setIndex] = useState(0)

        useEffect(() => {
            let timeout
            if (isInView && index < message.length) {
                timeout = setTimeout(() => {
                    setPart((prev) => prev + message[index])
                    setIndex(index + 1)
                }, speed)
            }
            return () => clearTimeout(timeout)
        }, [index, isInView])

        return <Component ref={ref} {...props} text={part} />
    }
}

Terms of Use for Free Assets

By accessing and using this Framer Override Library, you agree to the following terms:

All code snippets provided are available for your personal and professional use. This includes personal websites, client projects, and other website projects in Framer. You are strictly prohibited from sharing, redistributing, selling these code snippets, or creating derivative works for resale or distribution. Unauthorized sharing, distribution, or selling of these code snippets is a breach of these terms and may result in termination of your access to this library, along with potential legal action.