Text Effect
navdeep-singh/text-effectFreeComponent
Motion-based per-character / per-word text animation.
Install it
npx shadcn@latest add https://ui.navdeepsingh.dev/r/text-effect.jsonSource
1'use client'2import { cn } from '@/lib/utils'3import { AnimatePresence, motion } from 'motion/react'4import type { TargetAndTransition, Transition, Variant, Variants } from 'motion/react'5import React from 'react'67export type PresetType = 'blur' | 'fade-in-blur' | 'scale' | 'fade' | 'slide'89export type PerType = 'word' | 'char' | 'line'1011export type TextEffectProps = {12 children: string13 per?: PerType14 as?: keyof React.JSX.IntrinsicElements15 variants?: {16 container?: Variants17 item?: Variants18 }19 className?: string20 preset?: PresetType21 delay?: number22 speedReveal?: number23 speedSegment?: number24 trigger?: boolean25 onAnimationComplete?: () => void26 onAnimationStart?: () => void27 segmentWrapperClassName?: string28 containerTransition?: Transition29 segmentTransition?: Transition30 style?: React.CSSProperties31}3233const defaultStaggerTimes: Record<PerType, number> = {34 char: 0.03,35 word: 0.05,36 line: 0.1,37}3839const defaultContainerVariants: Variants = {40 hidden: { opacity: 0 },41 visible: {42 opacity: 1,43 transition: {44 staggerChildren: 0.05,45 },46 },47 exit: {48 transition: { staggerChildren: 0.05, staggerDirection: -1 },49 },50}5152const defaultItemVariants: Variants = {53 hidden: { opacity: 0 },54 visible: {55 opacity: 1,56 },57 exit: { opacity: 0 },58}5960const presetVariants: Record<PresetType, { container: Variants; item: Variants }> = {61 blur: {62 container: defaultContainerVariants,63 item: {64 hidden: { opacity: 0, filter: 'blur(12px)' },65 visible: { opacity: 1, filter: 'blur(0px)' },66 exit: { opacity: 0, filter: 'blur(12px)' },67 },68 },69 'fade-in-blur': {70 container: defaultContainerVariants,71 item: {72 hidden: { opacity: 0, y: 20, filter: 'blur(12px)' },73 visible: { opacity: 1, y: 0, filter: 'blur(0px)' },74 exit: { opacity: 0, y: 20, filter: 'blur(12px)' },75 },76 },77 scale: {78 container: defaultContainerVariants,79 item: {80 hidden: { opacity: 0, scale: 0 },81 visible: { opacity: 1, scale: 1 },82 exit: { opacity: 0, scale: 0 },83 },84 },85 fade: {86 container: defaultContainerVariants,87 item: {88 hidden: { opacity: 0 },89 visible: { opacity: 1 },90 exit: { opacity: 0 },91 },92 },93 slide: {94 container: defaultContainerVariants,95 item: {96 hidden: { opacity: 0, y: 20 },97 visible: { opacity: 1, y: 0 },98 exit: { opacity: 0, y: 20 },99 },100 },101}102103const AnimationComponent: React.FC<{104 segment: string105// … truncated
What it pulls in
npm packages
Files it writes
More from navdeep-singh
All 64 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Groupanimated-group | navdeep-singh | Components | Free | 1 dep | |
| Animated Numbersanimated-numbers | navdeep-singh | Components | Free | 1 dep | |
| Animated Tabsanimated-tabs | navdeep-singh | Components | Free | 2 deps | |
| Approval Panel Illustrationapproval-panel | navdeep-singh | Components | Free | 2 deps · 2 files | |
| Brand Logobrand-logo | navdeep-singh | Components | Free | 1 dep | |
| Contribution Graphcontribution-graph | navdeep-singh | Components | Free | no deps | |
| Designed for Focus Illustrationdesigned-for-focus-illustration | navdeep-singh | Components | Free | 1 dep | |
| Expandable Cardexpandable-card | navdeep-singh | Components | Free | 4 deps |
