UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
feat: fixed text-animate to use delay variants and duration pros (#563)
Arghya Das72ec07c34952
diff --git a/__registry__/index.tsx b/__registry__/index.tsxindex 81163156..50ba5fac 100644--- a/__registry__/index.tsx+++ b/__registry__/index.tsx@@ -3506,6 +3506,75 @@ export const Index: Record<string, any> = {}),meta: undefined,},+ "text-animate-demo-7": {+ name: "text-animate-demo-7",+ description: "Seventh example showing various text animations.",+ type: "registry:example",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-7.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-7.tsx",+ },+ ],+ component: React.lazy(async () => {+ const mod = await import("@/registry/example/text-animate-demo-7.tsx");+ const exportName =+ Object.keys(mod).find(+ (key) =>+ typeof mod[key] === "function" || typeof mod[key] === "object",+ ) || item.name;+ return { default: mod.default || mod[exportName] };+ }),+ meta: undefined,+ },+ "text-animate-demo-8": {+ name: "text-animate-demo-8",+ description: "Eighth example showing various text animations.",+ type: "registry:example",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-8.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-8.tsx",+ },+ ],+ component: React.lazy(async () => {+ const mod = await import("@/registry/example/text-animate-demo-8.tsx");+ const exportName =+ Object.keys(mod).find(+ (key) =>+ typeof mod[key] === "function" || typeof mod[key] === "object",+ ) || item.name;+ return { default: mod.default || mod[exportName] };+ }),+ meta: undefined,+ },+ "text-animate-demo-9": {+ name: "text-animate-demo-9",+ description: "Ninth example showing various text animations.",+ type: "registry:example",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-9.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-9.tsx",+ },+ ],+ component: React.lazy(async () => {+ const mod = await import("@/registry/example/text-animate-demo-9.tsx");+ const exportName =+ Object.keys(mod).find(+ (key) =>+ typeof mod[key] === "function" || typeof mod[key] === "object",+ ) || item.name;+ return { default: mod.default || mod[exportName] };+ }),+ meta: undefined,+ },"shiny-button-demo": {name: "shiny-button-demo",description: "Example showing a shiny button with dynamic styles.",diff --git a/content/docs/components/text-animate.mdx b/content/docs/components/text-animate.mdxindex e82dadf6..9ac55f20 100644--- a/content/docs/components/text-animate.mdx+++ b/content/docs/components/text-animate.mdx@@ -62,6 +62,18 @@ npx shadcn@latest add "https://magicui.design/r/text-animate"<ComponentPreview name="text-animate-demo-6" />+### With Delay++<ComponentPreview name="text-animate-demo-7" />++### With Duration++<ComponentPreview name="text-animate-demo-8" />++### With Custom Motion Variants++<ComponentPreview name="text-animate-demo-9" />+## Props| Prop | Type | Default | Description |diff --git a/public/r/text-animate-demo-7.json b/public/r/text-animate-demo-7.jsonnew file mode 100644index 00000000..1290ec15--- /dev/null+++ b/public/r/text-animate-demo-7.json@@ -0,0 +1,18 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "text-animate-demo-7",+ "type": "registry:example",+ "title": "Text Animate Demo 7",+ "description": "Seventh example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-7.tsx",+ "content": "import { TextAnimate } from \"@/components/magicui/text-animate\";\r\n\r\nexport default function TextAnimateDemo7() {\r\n return (\r\n <TextAnimate animation=\"blurInUp\" by=\"character\" delay={2}>\r\n Blur in by character\r\n </TextAnimate>\r\n );\r\n}\r\n",+ "type": "registry:example",+ "target": "components/text-animate-demo-7.tsx"+ }+ ]+}\ No newline at end of filediff --git a/public/r/text-animate-demo-8.json b/public/r/text-animate-demo-8.jsonnew file mode 100644index 00000000..b459353a--- /dev/null+++ b/public/r/text-animate-demo-8.json@@ -0,0 +1,18 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "text-animate-demo-8",+ "type": "registry:example",+ "title": "Text Animate Demo 8",+ "description": "Eighth example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-8.tsx",+ "content": "import { TextAnimate } from \"@/components/magicui/text-animate\";\r\n\r\nexport default function TextAnimateDemo8() {\r\n return (\r\n <TextAnimate animation=\"blurInUp\" by=\"character\" duration={5}>\r\n Blur in by character\r\n </TextAnimate>\r\n );\r\n}\r\n",+ "type": "registry:example",+ "target": "components/text-animate-demo-8.tsx"+ }+ ]+}\ No newline at end of filediff --git a/public/r/text-animate-demo-9.json b/public/r/text-animate-demo-9.jsonnew file mode 100644index 00000000..fc7b06cd--- /dev/null+++ b/public/r/text-animate-demo-9.json@@ -0,0 +1,18 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "text-animate-demo-9",+ "type": "registry:example",+ "title": "Text Animate Demo 9",+ "description": "Ninth example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-9.tsx",+ "content": "import { TextAnimate } from \"@/components/magicui/text-animate\";\r\n\r\nexport default function TextAnimateDemo8() {\r\n return (\r\n <TextAnimate\r\n variants={{\r\n hidden: {\r\n opacity: 0,\r\n y: 20,\r\n },\r\n show: (i) => ({\r\n opacity: 1,\r\n y: 0,\r\n transition: {\r\n delay: i * 0.1,\r\n duration: 0.6,\r\n y: {\r\n type: \"spring\",\r\n damping: 5,\r\n stiffness: 100,\r\n },\r\n },\r\n }),\r\n exit: (i) => ({\r\n opacity: 0,\r\n y: 20,\r\n transition: {\r\n delay: i * 0.1,\r\n },\r\n }),\r\n }}\r\n by=\"character\"\r\n >\r\n Wavy Motion!\r\n </TextAnimate>\r\n );\r\n}\r\n",+ "type": "registry:example",+ "target": "components/text-animate-demo-9.tsx"+ }+ ]+}\ No newline at end of filediff --git a/public/r/text-animate.json b/public/r/text-animate.jsonindex 2969da3e..23573898 100644--- a/public/r/text-animate.json+++ b/public/r/text-animate.json@@ -10,7 +10,7 @@"files": [{"path": "registry/magicui/text-animate.tsx",- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { AnimatePresence, motion, MotionProps, Variants } from \"motion/react\";\nimport { ElementType } from \"react\";\n\ntype AnimationType = \"text\" | \"word\" | \"character\" | \"line\";\ntype AnimationVariant =\n | \"fadeIn\"\n | \"blurIn\"\n | \"blurInUp\"\n | \"blurInDown\"\n | \"slideUp\"\n | \"slideDown\"\n | \"slideLeft\"\n | \"slideRight\"\n | \"scaleUp\"\n | \"scaleDown\";\n\ninterface TextAnimateProps extends MotionProps {\n /**\n * The text content to animate\n */\n children: string;\n /**\n * The class name to be applied to the component\n */\n className?: string;\n /**\n * The class name to be applied to each segment\n */\n segmentClassName?: string;\n /**\n * The delay before the animation starts\n */\n delay?: number;\n /**\n * The duration of the animation\n */\n duration?: number;\n /**\n * Custom motion variants for the animation\n */\n variants?: Variants;\n /**\n * The element type to render\n */\n as?: ElementType;\n /**\n * How to split the text (\"text\", \"word\", \"character\")\n */\n by?: AnimationType;\n /**\n * Whether to start animation when component enters viewport\n */\n startOnView?: boolean;\n /**\n * Whether to animate only once\n */\n once?: boolean;\n /**\n * The animation preset to use\n */\n animation?: AnimationVariant;\n}\n\nconst staggerTimings: Record<AnimationType, number> = {\n text: 0.06,\n word: 0.05,\n character: 0.03,\n line: 0.06,\n};\n\nconst defaultContainerVariants = {\n hidden: { opacity: 1 },\n show: {\n opacity: 1,\n transition: {\n staggerChildren: 0.05,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: 0.05,\n staggerDirection: -1,\n },\n },\n};\n\nconst defaultItemVariants: Variants = {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n};\n\nconst defaultItemAnimationVariants: Record<\n AnimationVariant,\n { container: Variants; item: Variants }\n> = {\n fadeIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, y: 20 },\n show: (delay: number) => ({\n opacity: 1,\n y: 0,\n transition: {\n delay,\n duration: 0.3,\n },\n }),\n exit: {\n opacity: 0,\n y: 20,\n transition: { duration: 0.3 },\n },\n },\n },\n blurIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\" },\n show: (i: number) => ({\n opacity: 1,\n filter: \"blur(0px)\",\n transition: {\n delay: i * 0.1,\n duration: 0.3,\n },\n }),\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n transition: { duration: 0.3 },\n },\n },\n },\n blurInUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: 20 },\n show: (delay: number) => ({\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n }),\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n y: 20,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n blurInDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: -20 },\n show: (delay: number) => ({\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n }),\n },\n },\n slideUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: 20, opacity: 0 },\n show: (delay: number) => ({\n y: 0,\n opacity: 1,\n transition: {\n delay,\n duration: 0.3,\n },\n }),\n exit: {\n y: -20,\n opacity: 0,\n transition: {\n duration: 0.3,\n },\n },\n },\n },\n slideDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: -20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n y: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideLeft: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: 20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: -20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideRight: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: -20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 0.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 0.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 1.5, opacity: 0 },\n show: (delay: number) => ({\n scale: 1,\n opacity: 1,\n transition: {\n delay,\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n }),\n exit: {\n scale: 1.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n};\n\nexport function TextAnimate({\n children,\n delay = 0,\n duration = 0.3,\n variants,\n className,\n segmentClassName,\n as: Component = \"p\",\n startOnView = true,\n once = false,\n by = \"word\",\n animation = \"fadeIn\",\n ...props\n}: TextAnimateProps) {\n const MotionComponent = motion.create(Component);\n\n // Use provided variants or default variants based on animation type\n const finalVariants = animation\n ? {\n container: {\n ...defaultItemAnimationVariants[animation].container,\n show: {\n ...defaultItemAnimationVariants[animation].container.show,\n transition: {\n staggerChildren: staggerTimings[by],\n },\n },\n exit: {\n ...defaultItemAnimationVariants[animation].container.exit,\n transition: {\n staggerChildren: staggerTimings[by],\n staggerDirection: -1,\n },\n },\n },\n item: defaultItemAnimationVariants[animation].item,\n }\n : { container: defaultContainerVariants, item: defaultItemVariants };\n\n let segments: string[] = [];\n switch (by) {\n case \"word\":\n segments = children.split(/(\\s+)/);\n break;\n case \"character\":\n segments = children.split(\"\");\n break;\n case \"line\":\n segments = children.split(\"\\n\");\n break;\n case \"text\":\n default:\n segments = [children];\n break;\n }\n\n return (\n <AnimatePresence mode=\"popLayout\">\n <MotionComponent\n variants={finalVariants.container}\n initial=\"hidden\"\n whileInView={startOnView ? \"show\" : undefined}\n animate={startOnView ? undefined : \"show\"}\n exit=\"exit\"\n className={cn(\"whitespace-pre-wrap\", className)}\n viewport={{ once }}\n {...props}\n >\n {segments.map((segment, i) => (\n <motion.span\n key={`${by}-${segment}-${i}`}\n variants={finalVariants.item}\n custom={i * staggerTimings[by]}\n className={cn(\n by === \"line\" ? \"block\" : \"inline-block whitespace-pre\",\n segmentClassName,\n )}\n >\n {segment}\n </motion.span>\n ))}\n </MotionComponent>\n </AnimatePresence>\n );\n}\n",+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { AnimatePresence, motion, MotionProps, Variants } from \"motion/react\";\nimport { ElementType } from \"react\";\n\ntype AnimationType = \"text\" | \"word\" | \"character\" | \"line\";\ntype AnimationVariant =\n | \"fadeIn\"\n | \"blurIn\"\n | \"blurInUp\"\n | \"blurInDown\"\n | \"slideUp\"\n | \"slideDown\"\n | \"slideLeft\"\n | \"slideRight\"\n | \"scaleUp\"\n | \"scaleDown\";\n\ninterface TextAnimateProps extends MotionProps {\n /**\n * The text content to animate\n */\n children: string;\n /**\n * The class name to be applied to the component\n */\n className?: string;\n /**\n * The class name to be applied to each segment\n */\n segmentClassName?: string;\n /**\n * The delay before the animation starts\n */\n delay?: number;\n /**\n * The duration of the animation\n */\n duration?: number;\n /**\n * Custom motion variants for the animation\n */\n variants?: Variants;\n /**\n * The element type to render\n */\n as?: ElementType;\n /**\n * How to split the text (\"text\", \"word\", \"character\")\n */\n by?: AnimationType;\n /**\n * Whether to start animation when component enters viewport\n */\n startOnView?: boolean;\n /**\n * Whether to animate only once\n */\n once?: boolean;\n /**\n * The animation preset to use\n */\n animation?: AnimationVariant;\n}\n\nconst staggerTimings: Record<AnimationType, number> = {\n text: 0.06,\n word: 0.05,\n character: 0.03,\n line: 0.06,\n};\n\nconst defaultContainerVariants = {\n hidden: { opacity: 1 },\n show: {\n opacity: 1,\n transition: {\n delayChildren: 0,\n staggerChildren: 0.05,\n },\n },\n exit: {\n opacity: 0,\n transition: {\n staggerChildren: 0.05,\n staggerDirection: -1,\n },\n },\n};\n\nconst defaultItemVariants: Variants = {\n hidden: { opacity: 0 },\n show: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n};\n\nconst defaultItemAnimationVariants: Record<\n AnimationVariant,\n { container: Variants; item: Variants }\n> = {\n fadeIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, y: 20 },\n show: {\n opacity: 1,\n y: 0,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n y: 20,\n transition: { duration: 0.3 },\n },\n },\n },\n blurIn: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\" },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n transition: { duration: 0.3 },\n },\n },\n },\n blurInUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: 20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n exit: {\n opacity: 0,\n filter: \"blur(10px)\",\n y: 20,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n blurInDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { opacity: 0, filter: \"blur(10px)\", y: -20 },\n show: {\n opacity: 1,\n filter: \"blur(0px)\",\n y: 0,\n transition: {\n y: { duration: 0.3 },\n opacity: { duration: 0.4 },\n filter: { duration: 0.3 },\n },\n },\n },\n },\n slideUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: 20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: {\n duration: 0.3,\n },\n },\n exit: {\n y: -20,\n opacity: 0,\n transition: {\n duration: 0.3,\n },\n },\n },\n },\n slideDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { y: -20, opacity: 0 },\n show: {\n y: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n y: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideLeft: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: 20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: -20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n slideRight: {\n container: defaultContainerVariants,\n item: {\n hidden: { x: -20, opacity: 0 },\n show: {\n x: 0,\n opacity: 1,\n transition: { duration: 0.3 },\n },\n exit: {\n x: 20,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleUp: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 0.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 0.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n scaleDown: {\n container: defaultContainerVariants,\n item: {\n hidden: { scale: 1.5, opacity: 0 },\n show: {\n scale: 1,\n opacity: 1,\n transition: {\n duration: 0.3,\n scale: {\n type: \"spring\",\n damping: 15,\n stiffness: 300,\n },\n },\n },\n exit: {\n scale: 1.5,\n opacity: 0,\n transition: { duration: 0.3 },\n },\n },\n },\n};\n\nexport function TextAnimate({\n children,\n delay = 0,\n duration = 0.3,\n variants,\n className,\n segmentClassName,\n as: Component = \"p\",\n startOnView = true,\n once = false,\n by = \"word\",\n animation = \"fadeIn\",\n ...props\n}: TextAnimateProps) {\n const MotionComponent = motion.create(Component);\n\n let segments: string[] = [];\n switch (by) {\n case \"word\":\n segments = children.split(/(\\s+)/);\n break;\n case \"character\":\n segments = children.split(\"\");\n break;\n case \"line\":\n segments = children.split(\"\\n\");\n break;\n case \"text\":\n default:\n segments = [children];\n break;\n }\n\n const showVariant = defaultItemAnimationVariants[animation].item.show;\n\n const finalVariants = animation\n ? {\n container: {\n ...defaultItemAnimationVariants[animation].container,\n show: {\n ...defaultItemAnimationVariants[animation].container.show,\n transition: {\n delayChildren: delay,\n staggerChildren: duration / segments.length,\n },\n },\n exit: {\n ...defaultItemAnimationVariants[animation].container.exit,\n transition: {\n staggerChildren: duration / segments.length,\n staggerDirection: -1,\n },\n },\n },\n\n item: {\n ...defaultItemAnimationVariants[animation].item,\n show: {\n ...defaultItemAnimationVariants[animation].item.show,\n transition: {\n ...((typeof showVariant !== \"function\" &&\n showVariant.transition) ||\n {}),\n ...(segments.length <= 1 && { duration: duration }),\n },\n },\n },\n }\n : { container: defaultContainerVariants, item: defaultItemVariants };\n\n return (\n <AnimatePresence mode=\"popLayout\">\n <MotionComponent\n variants={finalVariants.container}\n initial=\"hidden\"\n whileInView={startOnView ? \"show\" : undefined}\n animate={startOnView ? undefined : \"show\"}\n exit=\"exit\"\n className={cn(\"whitespace-pre-wrap\", className)}\n viewport={{ once }}\n {...props}\n >\n {segments.map((segment, i) => (\n <motion.span\n key={`${by}-${segment}-${i}`}\n variants={finalVariants.item}\n custom={i * staggerTimings[by]}\n className={cn(\n by === \"line\" ? \"block\" : \"inline-block whitespace-pre\",\n by === \"character\" && \"\",\n segmentClassName\n )}\n >\n {segment}\n </motion.span>\n ))}\n </MotionComponent>\n </AnimatePresence>\n );\n}\n","type": "registry:ui","target": "components/magicui/text-animate.tsx"}diff --git a/registry.json b/registry.jsonindex 5be0bb7b..78373032 100644--- a/registry.json+++ b/registry.json@@ -2771,6 +2771,54 @@}]},+ {+ "name": "text-animate-demo-7",+ "type": "registry:example",+ "title": "Text Animate Demo 7",+ "description": "Seventh example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-7.tsx",+ "type": "registry:example",+ "target": "components/text-animate-demo-7.tsx"+ }+ ]+ },+ {+ "name": "text-animate-demo-8",+ "type": "registry:example",+ "title": "Text Animate Demo 8",+ "description": "Eighth example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-8.tsx",+ "type": "registry:example",+ "target": "components/text-animate-demo-8.tsx"+ }+ ]+ },+ {+ "name": "text-animate-demo-9",+ "type": "registry:example",+ "title": "Text Animate Demo 9",+ "description": "Ninth example showing various text animations.",+ "registryDependencies": [+ "https://magicui.design/r/text-animate"+ ],+ "files": [+ {+ "path": "registry/example/text-animate-demo-9.tsx",+ "type": "registry:example",+ "target": "components/text-animate-demo-9.tsx"+ }+ ]+ },{"name": "shiny-button-demo","type": "registry:example",diff --git a/registry/example/text-animate-demo-7.tsx b/registry/example/text-animate-demo-7.tsxnew file mode 100644index 00000000..f9006980--- /dev/null+++ b/registry/example/text-animate-demo-7.tsx@@ -0,0 +1,9 @@+import { TextAnimate } from "@/registry/magicui/text-animate";++export default function TextAnimateDemo7() {+ return (+ <TextAnimate animation="blurInUp" by="character" delay={2}>+ Blur in by character+ </TextAnimate>+ );+}diff --git a/registry/example/text-animate-demo-8.tsx b/registry/example/text-animate-demo-8.tsxnew file mode 100644index 00000000..70470359--- /dev/null+++ b/registry/example/text-animate-demo-8.tsx@@ -0,0 +1,9 @@+import { TextAnimate } from "@/registry/magicui/text-animate";++export default function TextAnimateDemo8() {+ return (+ <TextAnimate animation="blurInUp" by="character" duration={5}>+ Blur in by character+ </TextAnimate>+ );+}diff --git a/registry/example/text-animate-demo-9.tsx b/registry/example/text-animate-demo-9.tsxnew file mode 100644index 00000000..67cba281--- /dev/null+++ b/registry/example/text-animate-demo-9.tsx@@ -0,0 +1,39 @@+"use client";++import { TextAnimate } from "@/registry/magicui/text-animate";++export default function TextAnimateDemo8() {+ return (+ <TextAnimate+ variants={{+ hidden: {+ opacity: 0,+ y: 20,+ },+ show: (i) => ({+ opacity: 1,+ y: 0,+ transition: {+ delay: i * 0.1,+ duration: 0.6,+ y: {+ type: "spring",+ damping: 5,+ stiffness: 100,+ },+ },+ }),+ exit: (i) => ({+ opacity: 0,+ y: 20,+ transition: {+ delay: i * 0.1,+ },+ }),+ }}+ by="character"+ >+ Wavy Motion!+ </TextAnimate>+ );+}diff --git a/registry/magicui/text-animate.tsx b/registry/magicui/text-animate.tsxindex 9e31b34a..af7ece5f 100644--- a/registry/magicui/text-animate.tsx+++ b/registry/magicui/text-animate.tsx@@ -76,6 +76,7 @@ const defaultContainerVariants = {show: {opacity: 1,transition: {+ delayChildren: 0,staggerChildren: 0.05,},},@@ -106,14 +107,13 @@ const defaultItemAnimationVariants: Record<container: defaultContainerVariants,item: {hidden: { opacity: 0, y: 20 },- show: (delay: number) => ({+ show: {opacity: 1,y: 0,transition: {- delay,duration: 0.3,},- }),+ },exit: {opacity: 0,y: 20,@@ -125,14 +125,13 @@ const defaultItemAnimationVariants: Record<container: defaultContainerVariants,item: {hidden: { opacity: 0, filter: "blur(10px)" },- show: (i: number) => ({+ show: {opacity: 1,filter: "blur(0px)",transition: {- delay: i * 0.1,duration: 0.3,},- }),+ },exit: {opacity: 0,filter: "blur(10px)",@@ -144,7 +143,7 @@ const defaultItemAnimationVariants: Record<container: defaultContainerVariants,item: {hidden: { opacity: 0, filter: "blur(10px)", y: 20 },- show: (delay: number) => ({+ show: {opacity: 1,filter: "blur(0px)",y: 0,@@ -153,7 +152,7 @@ const defaultItemAnimationVariants: Record<opacity: { duration: 0.4 },filter: { duration: 0.3 },},- }),+ },exit: {opacity: 0,filter: "blur(10px)",@@ -170,7 +169,7 @@ const defaultItemAnimationVariants: Record<container: defaultContainerVariants,item: {hidden: { opacity: 0, filter: "blur(10px)", y: -20 },- show: (delay: number) => ({+ show: {opacity: 1,filter: "blur(0px)",y: 0,@@ -179,21 +178,20 @@ const defaultItemAnimationVariants: Record<opacity: { duration: 0.4 },filter: { duration: 0.3 },},- }),+ },},},slideUp: {container: defaultContainerVariants,item: {hidden: { y: 20, opacity: 0 },- show: (delay: number) => ({+ show: {y: 0,opacity: 1,transition: {- delay,duration: 0.3,},- }),+ },exit: {y: -20,opacity: 0,@@ -278,11 +276,10 @@ const defaultItemAnimationVariants: Record<container: defaultContainerVariants,item: {hidden: { scale: 1.5, opacity: 0 },- show: (delay: number) => ({+ show: {scale: 1,opacity: 1,transition: {- delay,duration: 0.3,scale: {type: "spring",@@ -290,7 +287,7 @@ const defaultItemAnimationVariants: Record<stiffness: 300,},},- }),+ },exit: {scale: 1.5,opacity: 0,@@ -316,7 +313,25 @@ export function TextAnimate({}: TextAnimateProps) {const MotionComponent = motion.create(Component);- // Use provided variants or default variants based on animation type+ let segments: string[] = [];+ switch (by) {+ case "word":+ segments = children.split(/(\s+)/);+ break;+ case "character":+ segments = children.split("");+ break;+ case "line":+ segments = children.split("\n");+ break;+ case "text":+ default:+ segments = [children];+ break;+ }++ const showVariant = defaultItemAnimationVariants[animation].item.show;+const finalVariants = animation? {container: {@@ -324,38 +339,34 @@ export function TextAnimate({show: {...defaultItemAnimationVariants[animation].container.show,transition: {- staggerChildren: staggerTimings[by],+ delayChildren: delay,+ staggerChildren: duration / segments.length,},},exit: {...defaultItemAnimationVariants[animation].container.exit,transition: {- staggerChildren: staggerTimings[by],+ staggerChildren: duration / segments.length,staggerDirection: -1,},},},- item: defaultItemAnimationVariants[animation].item,++ item: {+ ...defaultItemAnimationVariants[animation].item,+ show: {+ ...defaultItemAnimationVariants[animation].item.show,+ transition: {+ ...((typeof showVariant !== "function" &&+ showVariant.transition) ||+ {}),+ ...(segments.length <= 1 && { duration: duration }),+ },+ },+ },}: { container: defaultContainerVariants, item: defaultItemVariants };- let segments: string[] = [];- switch (by) {- case "word":- segments = children.split(/(\s+)/);- break;- case "character":- segments = children.split("");- break;- case "line":- segments = children.split("\n");- break;- case "text":- default:- segments = [children];- break;- }-return (<AnimatePresence mode="popLayout"><MotionComponent@@ -375,6 +386,7 @@ export function TextAnimate({custom={i * staggerTimings[by]}className={cn(by === "line" ? "block" : "inline-block whitespace-pre",+ by === "character" && "",segmentClassName,)}>diff --git a/registry/registry-examples.ts b/registry/registry-examples.tsindex 2d839e2c..ebbb139c 100644--- a/registry/registry-examples.ts+++ b/registry/registry-examples.ts@@ -1200,6 +1200,48 @@ export const examples: Registry["items"] = [},],},+ {+ name: "text-animate-demo-7",+ type: "registry:example",+ title: "Text Animate Demo 7",+ description: "Seventh example showing various text animations.",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-7.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-7.tsx",+ },+ ],+ },+ {+ name: "text-animate-demo-8",+ type: "registry:example",+ title: "Text Animate Demo 8",+ description: "Eighth example showing various text animations.",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-8.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-8.tsx",+ },+ ],+ },+ {+ name: "text-animate-demo-9",+ type: "registry:example",+ title: "Text Animate Demo 9",+ description: "Ninth example showing various text animations.",+ registryDependencies: ["https://magicui.design/r/text-animate"],+ files: [+ {+ path: "registry/example/text-animate-demo-9.tsx",+ type: "registry:example",+ target: "components/text-animate-demo-9.tsx",+ },+ ],+ },{name: "shiny-button-demo",type: "registry:example",