font-weight-text
eldoraui/font-weight-textFreeComponent
A font weight text component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/font-weight-text.jsonSource
1"use client"23import { useEffect, useRef } from "react"45import { cn } from "@/lib/utils"67interface FontWeightTextProps {8 text: string9 className?: string10 fontSize?: number11 minWeight?: number12 maxWeight?: number13 animationDuration?: number14 delayMultiplier?: number15}1617export function FontWeightText({18 text,19 className = "",20 fontSize = 150,21 minWeight = 0,22 maxWeight = 840,23 animationDuration = 1.5,24 delayMultiplier = 0.25,25}: FontWeightTextProps) {26 const containerRef = useRef<HTMLParagraphElement>(null)2728 useEffect(() => {29 if (!containerRef.current) return3031 const spans = containerRef.current.querySelectorAll("span")32 const numLetters = spans.length3334 spans.forEach((span, i) => {35 const mappedIndex = i - numLetters / 236 span.style.animationDelay = mappedIndex * delayMultiplier + "s"37 })38 }, [text, delayMultiplier])3940 const characters = text.split("").map((char, index) => (41 <span42 key={index}43 aria-hidden="true"44 style={{45 animation: `breath ${animationDuration}s alternate cubic-bezier(0.37, 0, 0.63, 1) infinite`,46 animationFillMode: "both",47 fontVariationSettings: `"wght" ${minWeight}`,48 }}49 >50 {char}51 </span>52 ))5354 return (55 <div className="flex items-center justify-center">56 <p57 className={cn("m-0 font-sans", className)}58 ref={containerRef}59 aria-label={text}60 style={{61 fontSize: `${fontSize}px`,62 fontFeatureSettings: '"wght"',63 }}64 >65 {characters}66 <style jsx>{`67 @keyframes breath {68 0% {69 font-variation-settings: "wght" ${minWeight};70 }71 100% {72 font-variation-settings: "wght" ${maxWeight};73 }74 }75 `}</style>76 </p>77 </div>78 )79}
What it pulls in
npm packages
Other registry items
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
