BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fancy/variable-font-hover-by-random-letter

Variable Font Hover By Random Letter

fancy/variable-font-hover-by-random-letter
FreeComponent

A ui component.

Install it

npx shadcn@latest add https://www.fancycomponents.dev/r/variable-font-hover-by-random-letter.json

Source

fancy/text/variable-font-hover-by-random-letter.tsxwww.fancycomponents.dev/r/variable-font-hover-by-random-letter.json
1"use client"
2
3import { useMemo } from "react"
4import { motion, Transition } from "motion/react"
5
6// Function to shuffle an array
7function shuffleArray(array: number[]) {
8 for (let i = array.length - 1; i > 0; i--) {
9 const j = Math.floor(Math.random() * (i + 1))
10 ;[array[i], array[j]] = [array[j], array[i]]
11 }
12}
13
14interface TextProps {
15 label: string
16 fromFontVariationSettings: string
17 toFontVariationSettings: string
18 transition?: Transition
19 staggerDuration?: number
20 className?: string
21 onClick?: () => void
22}
23
24const VariableFontHoverByRandomLetter = ({
25 label,
26 fromFontVariationSettings = "'wght' 400, 'slnt' 0",
27 toFontVariationSettings = "'wght' 900, 'slnt' -10",
28 transition = {
29 type: "spring",
30 duration: 0.7,
31 },
32 staggerDuration = 0.03,
33 className,
34 onClick,
35 ...props
36}: TextProps) => {
37 const shuffledIndices = useMemo(() => {
38 const indices = Array.from({ length: label.length }, (_, i) => i)
39 shuffleArray(indices)
40 return indices
41 }, [label])
42
43 const letterVariants = {
44 hover: (index: number) => ({
45 fontVariationSettings: toFontVariationSettings,
46 transition: {
47 ...transition,
48 delay: staggerDuration * index,
49 },
50 }),
51 initial: (index: number) => ({
52 fontVariationSettings: fromFontVariationSettings,
53 transition: {
54 ...transition,
55 delay: staggerDuration * index,
56 },
57 }),
58 }
59
60 return (
61 <motion.span
62 className={`${className}`}
63 onClick={onClick}
64 whileHover="hover"
65 initial="initial"
66 {...props}
67 >
68 <span className="sr-only">{label}</span>
69
70 {label.split("").map((letter: string, i: number) => {
71 const index = shuffledIndices[i]
72 return (
73 <motion.span
74 key={i}
75 className="inline-block whitespace-pre"
76 aria-hidden="true"
77 variants={letterVariants}
78 custom={index}
79 >
80 {letter}
81 </motion.span>
82 )
83 })}
84 </motion.span>
85 )
86}
87
88export default VariableFontHoverByRandomLetter

What it pulls in

npm packages

  • motion

Files it writes

  • fancy/text/variable-font-hover-by-random-letter

Facts

Registry
fancy
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
today

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
BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex