Line Shadow Text
magicui/line-shadow-textFreeComponent
A text component with a moving line shadow.
Live preview
live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://magicui.design/r/line-shadow-text.jsonSource
1"use client"23import { type CSSProperties, type HTMLAttributes } from "react"4import {5 motion,6 type DOMMotionComponents,7 type MotionProps,8} from "motion/react"910import { cn } from "@/lib/utils"1112const motionElements = {13 article: motion.article,14 div: motion.div,15 h1: motion.h1,16 h2: motion.h2,17 h3: motion.h3,18 h4: motion.h4,19 h5: motion.h5,20 h6: motion.h6,21 li: motion.li,22 p: motion.p,23 section: motion.section,24 span: motion.span,25} as const2627type MotionElementType = Extract<28 keyof DOMMotionComponents,29 keyof typeof motionElements30>3132interface LineShadowTextProps33 extends Omit<HTMLAttributes<HTMLElement>, keyof MotionProps>, MotionProps {34 children: string35 shadowColor?: string36 as?: MotionElementType37}3839export function LineShadowText({40 children,41 shadowColor = "black",42 className,43 as: Component = "span",44 ...props45}: LineShadowTextProps) {46 const MotionComponent = motionElements[Component]4748 return (49 <MotionComponent50 style={{ "--shadow-color": shadowColor } as CSSProperties}51 className={cn(52 "relative z-0 inline-flex",53 "after:absolute after:top-[0.04em] after:left-[0.04em] after:content-[attr(data-text)]",54 "after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]",55 "after:-z-10 after:bg-size-[0.06em_0.06em] after:bg-clip-text after:text-transparent",56 "after:animate-line-shadow",57 className58 )}59 data-text={children}60 {...props}61 >62 {children}63 </MotionComponent>64 )65}
What it pulls in
npm packages
Files it writes
More from magicui
All 247 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Androidandroid | magicui | Components | Free | no deps | |
| Animated Beamanimated-beam | magicui | Components | Free | 1 dep | |
| Animated Circular Progress Baranimated-circular-progress-bar | magicui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | magicui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | magicui | Components | Free | 1 dep | |
| Animated Listanimated-list | magicui | Components | Free | 1 dep | |
| Animated Shiny Textanimated-shiny-text | magicui | Components | Free | no deps | |
| Theme Toggleranimated-theme-toggler | magicui | Components | Free | 1 dep |
