BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fancy/underline-to-background

Underline To Background

fancy/underline-to-background
FreeComponent

A ui component.

Install it

npx shadcn@latest add https://www.fancycomponents.dev/r/underline-to-background.json

Source

fancy/text/underline-to-background.tsxwww.fancycomponents.dev/r/underline-to-background.json
1"use client"
2
3import { ElementType, useEffect, useMemo, useRef } from "react"
4import { motion, ValueAnimationTransition } from "motion/react"
5
6import { cn } from "@/lib/utils"
7
8interface UnderlineProps {
9 /**
10 * The content to be displayed and animated
11 */
12 children: React.ReactNode
13
14 /**
15 * HTML Tag to render the component as
16 * @default span
17 */
18 as?: ElementType
19
20 /**
21 * Optional class name for styling
22 */
23 className?: string
24
25 /**
26 * Animation transition configuration
27 * @default { type: "spring", damping: 30, stiffness: 300 }
28 */
29 transition?: ValueAnimationTransition
30
31 /**
32 * The color that the text will animate to on hover
33 */
34 targetTextColor: string
35
36 /**
37 * Height of the underline as a ratio of font size
38 * @default 0.1
39 */
40 underlineHeightRatio?: number
41
42 /**
43 * Padding of the underline as a ratio of font size
44 * @default 0.01
45 */
46 underlinePaddingRatio?: number
47}
48
49const UnderlineToBackground = ({
50 children,
51 as,
52 className,
53 transition = { type: "spring", damping: 30, stiffness: 300 },
54 underlineHeightRatio = 0.1, // Default to 10% of font size
55 underlinePaddingRatio = 0.01, // Default to 1% of font size
56 targetTextColor = "#fef",
57 ...props
58}: UnderlineProps) => {
59 const textRef = useRef<HTMLSpanElement>(null)
60
61 // Create custom motion component based on the 'as' prop
62 const MotionComponent = useMemo(() => motion.create(as ?? "span"), [as])
63
64 // Update CSS custom properties based on font size
65 useEffect(() => {
66 const updateUnderlineStyles = () => {
67 if (textRef.current) {
68 const fontSize = parseFloat(getComputedStyle(textRef.current).fontSize)
69 const underlineHeight = fontSize * underlineHeightRatio
70 const underlinePadding = fontSize * underlinePaddingRatio
71 textRef.current.style.setProperty(
72 "--underline-height",
73 `${underlineHeight}px`
74 )
75 textRef.current.style.setProperty(
76 "--underline-padding",
77 `${underlinePadding}px`
78 )
79 }
80 }
81
82 updateUnderlineStyles()
83 window.addEventListener("resize", updateUnderlineStyles)
84
85 return () => window.removeEventListener("resize", updateUnderlineStyles)
86 }, [underlineHeightRatio, underlinePaddingRatio])
87
88 // Animation variants for the underline background
89 const underlineVariants = {
90 initial: {
91 height: "var(--underline-height)",
92 },
93 target: {
94 height: "100%",
95 transition: transition,
96 },
97 }
98
99// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • fancy/text/underline-to-background

Facts

Registry
fancy
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
In the index
at or before 2026-08-13
Last confirmed
yesterday

Go to the source

www.fancycomponents.dev danielpetho/fancy on GitHub Raw registry item This item as JSON

More from fancy

All 158 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Gradient With Svganimated-gradient-with-svgfancyComponentsFreeno deps
Basic Number Tickerbasic-number-tickerfancyComponentsFree1 dep
Box Carouselbox-carouselfancyComponentsFree1 dep
Breathing Textbreathing-textfancyComponentsFree1 dep
Circling Elementscircling-elementsfancyComponentsFree1 dep
Css Boxcss-boxfancyComponentsFree1 dep
Cursor Attractor And Gravitycursor-attractor-and-gravityfancyComponentsFree5 deps
Drag Elementsdrag-elementsfancyComponentsFree1 dep

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex