Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

feat: letter-pullup (#36)

Tomonari Feehand5a71e13d0c5
diff --git a/config/docs.ts b/config/docs.ts
index bbeb670e..c6d2ca10 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -181,6 +181,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "New",
},
+ {
+ title: "Letter Pullup",
+ href: `/docs/components/letter-pullup`,
+ items: [],
+ label: "New",
+ },
],
},
{
diff --git a/content/docs/components/letter-pullup.mdx b/content/docs/components/letter-pullup.mdx
new file mode 100644
index 00000000..145b2050
--- /dev/null
+++ b/content/docs/components/letter-pullup.mdx
@@ -0,0 +1,31 @@
+---
+title: Staggered Letter Pull Up Animation
+date: 2024-05-22
+description: Staggered letter pull up text animation.
+author: tomonarifeehan
+published: true
+---
+
+<ComponentPreview name = "letter-pullup-demo" />
+
+<Steps>
+
+### Installation
+
+Copy and paste the following code into your project.
+
+```text
+components/magicui/letter-pullup.tsx
+```
+
+<ComponentSource name = "letter-pullup" />
+
+</Steps>
+
+## Props
+
+| Prop | Type | Description | Default |
+| ----------- | --------------- | -------------------------------------------------- | -------------------------- |
+| className | string | The class name to be applied to the component | |
+| words | string | Text to animate | "Staggered Letter Pull Up" |
+| delay | number | Delay each letter's animation by this many seconds | 0.05 |
\ No newline at end of file
diff --git a/registry/components/example/letter-pullup-demo.tsx b/registry/components/example/letter-pullup-demo.tsx
new file mode 100644
index 00000000..04e36475
--- /dev/null
+++ b/registry/components/example/letter-pullup-demo.tsx
@@ -0,0 +1,11 @@
+import LetterPullup from "@/registry/components/magicui/letter-pullup";
+
+ export default async function LetterPullupDemo() {
+ return (
+ <LetterPullup
+ className = "text-black"
+ words = { "Staggered Letter Pull Up" }
+ delay = { 0.05 }
+ />
+ );
+ }
\ No newline at end of file
diff --git a/registry/components/magicui/letter-pullup.tsx b/registry/components/magicui/letter-pullup.tsx
new file mode 100644
index 00000000..f6abcca4
--- /dev/null
+++ b/registry/components/magicui/letter-pullup.tsx
@@ -0,0 +1,52 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { motion } from "framer-motion";
+
+interface LetterPullupProps {
+ className?: string;
+ words: string;
+ delay?: number
+}
+
+export default function LetterPullup({
+ className,
+ words,
+ delay
+
+}: LetterPullupProps) {
+
+ const letters = words.split("");
+
+ const pullupVariant = {
+ initial: { y: 100, opacity: 0 },
+ animate: (i: any) => ({
+ y: 0,
+ opacity: 1,
+ transition: {
+ delay: i * (delay ? delay : 0.05), // By default, delay each letter's animation by 0.05 seconds
+ },
+ }),
+ };
+
+ return (
+ <div className = "flex justify-center">
+
+ { letters.map((letter, i) => (
+
+ <motion.h1
+ key = { i }
+ variants = { pullupVariant }
+ initial = "initial"
+ animate = "animate"
+ custom = { i }
+ className = { cn("text-center font-display text-4xl font-bold tracking-[-0.02em] drop-shadow-sm md:text-4xl md:leading-[5rem]", className) }
+ >
+ {letter === " " ? <span>&nbsp;</span> : letter}
+ </motion.h1>
+
+ ))}
+
+ </div>
+ );
+}
diff --git a/registry/index.tsx b/registry/index.tsx
index 0b090de2..1614f626 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -162,6 +162,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/separate-away.tsx"],
},
+ "letter-pullup": {
+ name: "letter-pullup",
+ type: "components:ui",
+ files: ["registry/components/magicui/letter-pullup.tsx"],
+ },
};
const example: Registry = {
@@ -625,6 +630,14 @@ const example: Registry = {
() => import("@/registry/components/example/scroll-based-velocity-demo"),
),
},
+ "letter-pullup-demo": {
+ name: "letter-pullup-demo",
+ type: "components:example",
+ files: ["registry/components/example/letter-pullup-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/letter-pullup-demo"),
+ ),
+ },
};
export const registry: Registry = {