UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
feat: add word fade in component (#53)
Shriprasanna1231ce70f5f5
diff --git a/config/docs.ts b/config/docs.tsindex 86b0b174..5d2eea9c 100644--- a/config/docs.ts+++ b/config/docs.ts@@ -213,6 +213,12 @@ export const docsConfig: DocsConfig = {items: [],label: "New",},+ {+ title: "Word Fade In",+ href: `/docs/components/word-fade-in`,+ items: [],+ label: "New",+ },],},{diff --git a/content/docs/components/word-fade-in.mdx b/content/docs/components/word-fade-in.mdxnew file mode 100644index 00000000..1b9cd394--- /dev/null+++ b/content/docs/components/word-fade-in.mdx@@ -0,0 +1,32 @@+---+title: Word Fade In+date: 2024-05-24+description: Text animation which fades in word by word+author: shrix1+published: true+---++<ComponentPreview name="word-fade-in-demo" />++<Steps>++### Installation++Copy and paste the following code into your project.++```text+components/magicui/word-fade-in.tsx+```++<ComponentSource name="word-fade-in" />++</Steps>++## Props++| Prop | Type | Description | Default |+| --------- | -------- | -------------------------------------------------- | -------------- |+| className | string | The class name to be applied to the component | |+| delay | number | The Delay between each word animation | 0.15 |+| words | string | A Text that is animated word by word | "word fade in" |+| variants | Variants | An object containing framer-motion animation props | {} |diff --git a/registry/components/example/word-fade-in-demo.tsx b/registry/components/example/word-fade-in-demo.tsxnew file mode 100644index 00000000..b2f28439--- /dev/null+++ b/registry/components/example/word-fade-in-demo.tsx@@ -0,0 +1,5 @@+import WordFadeIn from "@/registry/components/magicui/word-fade-in";++export default async function WordFadeInDemo() {+ return <WordFadeIn words="Word Fade In" />;+}diff --git a/registry/components/magicui/word-fade-in.tsx b/registry/components/magicui/word-fade-in.tsxnew file mode 100644index 00000000..6c122dc9--- /dev/null+++ b/registry/components/magicui/word-fade-in.tsx@@ -0,0 +1,45 @@+"use client";++import { cn } from "@/lib/utils";+import { Variants, motion } from "framer-motion";++interface WordFadeInProps {+ words: string;+ className?: string;+ delay?: number;+ variants?: Variants;+}++export default function WordFadeIn({+ words,+ delay = 0.15,+ variants = {+ hidden: { opacity: 0 },+ visible: (i: any) => ({+ y: 0,+ opacity: 1,+ transition: { delay: i * delay },+ }),+ },+ className,+}: WordFadeInProps) {+ const _words = words.split(" ");++ return (+ <motion.h1+ variants={variants}+ initial="hidden"+ animate="visible"+ className={cn(+ "font-display text-center text-4xl font-bold tracking-[-0.02em] text-black drop-shadow-sm dark:text-white md:text-7xl md:leading-[5rem]",+ className,+ )}+ >+ {_words.map((word, i) => (+ <motion.span key={word} variants={variants} custom={i}>+ {word}{" "}+ </motion.span>+ ))}+ </motion.h1>+ );+}diff --git a/registry/components/magicui/word-pull-up.tsx b/registry/components/magicui/word-pull-up.tsxindex bdab54bb..acc429fe 100644--- a/registry/components/magicui/word-pull-up.tsx+++ b/registry/components/magicui/word-pull-up.tsx@@ -5,7 +5,6 @@ import { cn } from "lib/utils";interface WordPullUpProps {words: string;- duration?: number;delayMultiple?: number;wrapperFramerProps?: Variants;framerProps?: Variants;diff --git a/registry/index.tsx b/registry/index.tsxindex 26b50bb6..ebf3acb4 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -192,6 +192,11 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/gradual-spacing.tsx"],},+ "word-fade-in": {+ name: "word-fade-in",+ type: "components:ui",+ files: ["registry/components/magicui/word-fade-in.tsx"],+ },};const example: Registry = {@@ -703,6 +708,14 @@ const example: Registry = {() => import("@/registry/components/example/gradual-spacing-demo"),),},+ "word-fade-in-demo": {+ name: "word-fade-in-demo",+ type: "components:example",+ files: ["registry/components/example/word-fade-in-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/word-fade-in-demo"),+ ),+ },};export const registry: Registry = {...ui,