fade-text
eldoraui/fade-textFreeComponent
A combined fade text component with support for in, up, and down directions.
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/fade-text.jsonSource
1"use client"23import React from "react"4import clsx from "clsx"5import { motion } from "motion/react"67type FadeDirection = "in" | "up" | "down"89interface FadeTextProps {10 text?: string11 className?: string12 direction?: FadeDirection13 staggerDelay?: number14 wordDelay?: number15}1617export const FadeText: React.FC<FadeTextProps> = ({18 text = "",19 className = "",20 direction = "in",21 staggerDelay = 0.15,22 wordDelay = 0.1,23}) => {24 // For "in" direction, we animate word by word25 if (direction === "in") {26 const words = text.split(" ")2728 return (29 <motion.div30 initial="hidden"31 animate="visible"32 viewport={{ once: true }}33 variants={{34 hidden: {},35 visible: {36 transition: {37 staggerChildren: wordDelay,38 },39 },40 }}41 >42 <motion.h143 className={clsx(44 "font-display text-center font-bold drop-shadow-sm",45 "text-4xl md:text-5xl lg:text-6xl xl:text-7xl",46 "tracking-[-0.02em]",47 "md:leading-[4rem] lg:leading-[4.5rem] xl:leading-[5rem]",48 className49 )}50 >51 {words.map((word, i) => (52 <motion.span53 key={`${word}-${i}`}54 variants={{55 hidden: { opacity: 0 },56 visible: { opacity: 1 },57 }}58 >59 {word}{" "}60 </motion.span>61 ))}62 </motion.h1>63 </motion.div>64 )65 }6667 // For "up" and "down" directions, we animate the entire text68 const animationVariants =69 direction === "up"70 ? {71 hidden: { opacity: 0, y: 20 },72 show: {73 opacity: 1,74 y: 0,75 transition: {76 type: "spring" as const,77 stiffness: 100,78 damping: 12,79 duration: 0.8,80 },81 },82 }83 : {84 hidden: { opacity: 0, y: -20 },85 show: {86 opacity: 1,87 y: 0,88 transition: {89 type: "spring" as const,90 stiffness: 100,91 damping: 12,92 duration: 0.8,93 },94 },95 }9697 return (98 <motion.div99 initial="hidden"100 animate="show"101 viewport={{ once: true }}102 transition={{ delay: staggerDelay }}103 >104 <motion.h1105 className={clsx(106 "font-display text-center font-bold drop-shadow-sm",107// … truncated
What it pulls in
npm packages
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 |
