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/Font Weight Text

Text effects
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.

Font Weight Text

A font weight text component.

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

Code

registry/eldoraui/font-weight-text.tsx

"use client"

import { useEffect, useRef } from "react"

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

interface FontWeightTextProps {
  text: string
  className?: string
  fontSize?: number
  minWeight?: number
  maxWeight?: number
  animationDuration?: number
  delayMultiplier?: number
}

export function FontWeightText({
  text,
  className = "",
  fontSize = 150,
  minWeight = 0,
  maxWeight = 840,
  animationDuration = 1.5,
  delayMultiplier = 0.25,
}: FontWeightTextProps) {
  const containerRef = useRef<HTMLParagraphElement>(null)

  useEffect(() => {
    if (!containerRef.current) return

    const spans = containerRef.current.querySelectorAll("span")
    const numLetters = spans.length

    spans.forEach((span, i) => {
      const mappedIndex = i - numLetters / 2
      span.style.animationDelay = mappedIndex * delayMultiplier + "s"
    })
  }, [text, delayMultiplier])

  const characters = text.split("").map((char, index) => (
    <span
      key={index}
      aria-hidden="true"
      style={{
        animation: `breath ${animationDuration}s alternate cubic-bezier(0.37, 0, 0.63, 1) infinite`,
        animationFillMode: "both",
        fontVariationSettings: `"wght" ${minWeight}`,
      }}
    >
      {char}
    </span>
  ))

  return (
    <div className="flex items-center justify-center">
      <p
        className={cn("m-0 font-sans", className)}
        ref={containerRef}
        aria-label={text}
        style={{
          fontSize: `${fontSize}px`,
          fontFeatureSettings: '"wght"',
        }}
      >
        {characters}
        <style jsx>{`
          @keyframes breath {
            0% {
              font-variation-settings: "wght" ${minWeight};
            }
            100% {
              font-variation-settings: "wght" ${maxWeight};
            }
          }
        `}</style>
      </p>
    </div>
  )
}

More like this

Live Button

Eldora UI·Buttons

Animated Shiny Button

Eldora UI·Text effects

Particle Text

React Bits·Text effectsMIT+

Rotating Text

React Bits·Text effectsMIT+

Masked Heading

React Bits·Text effectsMIT+

Stroke Text

React Bits·Text effectsMIT+

Drawer

HextaUI·Overlays

Mobile
Scroll Float

React Bits·Text effectsMIT+

Fade Text

Eldora UI·Text effects

Shuffle

React Bits·Text effectsMIT+

Drape Background

Kokonut UI·Backgrounds

Tilt

Motion Primitives·Cards

Magnet

React Bits·Cursor & effectsMIT+

Split Text

React Bits·Text effectsMIT+

Metallic Paint

React Bits·BackgroundsMIT+