UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

Eldora UI/Dock Text

Text effects
1 of 25
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

25 versions·4 librariesCompare all text animations →

  • Dock Text
  • Text Animate
  • Text Gif
  • Blur In Text
  • Fade Text
  • Font Weight Text
  • Gradual Spacing Text
  • Letter Pull Up Text
  • Multi Direction Slide Text
  • Scale Letter Text
  • Seperate Away Text
  • Wavy Text
  • Word Pull Up Text
  • Ai Text Loading
  • Cradle Text
  • Plucked Text
  • Swoosh Text
  • Animated Gradient Text
  • Animated Shiny Text
  • Comic Text
  • Dia Text Reveal
  • Hyper Text
  • Kinetic Text
  • Line Shadow Text
  • Morphing Text

Dock Text

A dock text component with interactive hover effects.

npx shadcn@latest add https://eldoraui.site/r/dock-text.json
Open in v0 Docs Repo
Library
Eldora UI
License
MIT
Stack
React · Tailwind CSS · animated
Packages
motion
Size
82 lines
Demo
From Eldora UI

Code

registry/eldoraui/dock-text.tsx

"use client"

import React, { useRef, useState } from "react"
import { motion } from "motion/react"

import { cn } from "@/lib/utils"

interface DockTextProps {
  text: string
  down?: boolean
  className?: string
}

export default function DockText({
  text,
  down = false,
  className,
}: DockTextProps) {
  const [hoveredIndex, setHoveredIndex] = useState<number | null>(null)
  const containerRef = useRef<HTMLHeadingElement>(null)

  const handleMouseMove = (e: React.MouseEvent<HTMLHeadingElement>) => {
    const container = containerRef.current
    if (!container) return

    const letters = container.children
    const containerRect = container.getBoundingClientRect()
    const mouseX = e.clientX - containerRect.left

    Array.from(letters).forEach((letter, index) => {
      const letterRect = letter.getBoundingClientRect()
      const letterCenterX =
        letterRect.left + letterRect.width / 2 - containerRect.left
      const distance = Math.abs(mouseX - letterCenterX)

      if (distance <= 10) {
        setHoveredIndex(index)
      }
    })
  }

  const handleMouseLeave = () => {
    setHoveredIndex(null)
  }

  return (
    <motion.h1
      ref={containerRef}
      onMouseMove={handleMouseMove}
      onMouseLeave={handleMouseLeave}
      className={cn(
        "my-8 flex cursor-pointer items-center text-6xl font-bold text-gray-900 uppercase md:text-7xl lg:text-8xl dark:text-white",
        className
      )}
    >
      {text.split("").map((letter, index) => (
        <motion.span
          key={index}
          animate={{
            scaleY:
              hoveredIndex === null
                ? 1
                : Math.max(1, 1.3638 - Math.abs(index - hoveredIndex) * 0.1),
          }}
          transition={{
            type: "spring",
            stiffness: 150,
            damping: 20,
            mass: 0.5,
          }}
          style={{
            display: "inline-block",
            transformOrigin: down ? "top" : "bottom",
          }}
        >
          {letter}
        </motion.span>
      ))}
    </motion.h1>
  )
}

More like this

Drape Background

Kokonut UI·Backgrounds

Fuzzy Text

React Bits·Text effectsMIT+

Card Nav

React Bits·NavigationMIT+

Aspect Ratio

shadcn/ui·Data display

Noise Texture

Magic UI·Backgrounds

Split Flap Text

React Bits·Text effectsMIT+

Kinetic Text

Magic UI·Text effects

Scroll Index

Kokonut UI·Text effects

8-bit Health Bar

8bitcn·Feedback & loaders

8-bit Mana Bar

8bitcn·Feedback & loaders

8-bit Progress

8bitcn·Feedback & loaders

Glyph Background

Animate UI·BackgroundsMIT+

Bubble Menu

React Bits·BackgroundsMIT+

ASCII Text

React Bits·Text effectsMIT+

Text Cursor

React Bits·Text effectsMIT+