Skip to content

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

feat: Slight Flip added (#38)

Abhishek Singh43efa516b829
diff --git a/config/docs.ts b/config/docs.ts
index 133247dc..10c9be34 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -199,6 +199,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "New",
},
+ {
+ title: "Flip Text",
+ href: `/docs/components/flip-text`,
+ items: [],
+ label: "New",
+ },
],
},
{
diff --git a/content/docs/components/flip-text.mdx b/content/docs/components/flip-text.mdx
new file mode 100644
index 00000000..a2754458
--- /dev/null
+++ b/content/docs/components/flip-text.mdx
@@ -0,0 +1,33 @@
+---
+title: Flip Text
+date: 2024-05-23
+description: Word animation for characters flip
+author: wellitsabhi
+published: true
+---
+
+<ComponentPreview name="flip-text-demo" />
+
+<Steps>
+
+### Installation
+
+Copy and paste the following code into your project.
+
+```text
+components/magicui/flip-text-demo.tsx
+```
+
+<ComponentSource name="flip-text-demo" />
+
+</Steps>
+
+## Props
+
+| Prop | Type | Description | Default |
+| ------------- | --------------- | -------------------------------------------------- | ------- |
+| className | string | The class name to be applied to the component | |
+| duration | number | The class name to be applied to the shimmer. | 0.2 |
+| delayMultiple | number | The class name to be applied to the shimmer. | 0.08 |
+| word | string | An array of words to rotate through | "" |
+| framerProps | HTMLMotionProps | An object containing framer-motion animation props | {} |
diff --git a/registry/components/example/flip-text-demo.tsx b/registry/components/example/flip-text-demo.tsx
new file mode 100644
index 00000000..3b1f2101
--- /dev/null
+++ b/registry/components/example/flip-text-demo.tsx
@@ -0,0 +1,10 @@
+import FlipText from "@/registry/components/magicui/flip-text";
+
+export default async function FlipTextDemo() {
+ return (
+ <FlipText
+ className="text-4xl font-bold tracking-[-0.1em] text-black dark:text-white md:text-7xl md:leading-[5rem]"
+ word="Flip Text"
+ />
+ );
+}
diff --git a/registry/components/magicui/flip-text.tsx b/registry/components/magicui/flip-text.tsx
new file mode 100644
index 00000000..1d18e7a3
--- /dev/null
+++ b/registry/components/magicui/flip-text.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { AnimatePresence, Variants, motion } from "framer-motion";
+
+interface SlightFlipProps {
+ word: string;
+ duration?: number;
+ delayMultiple?: number;
+ framerProps?: Variants;
+ className?: string;
+}
+
+export default function SlightFlip({
+ word,
+ duration = 0.5,
+ delayMultiple = 0.08,
+ framerProps = {
+ hidden: { rotateX: -90, opacity: 0 },
+ visible: { rotateX: 0, opacity: 1 },
+ },
+ className,
+}: SlightFlipProps) {
+ return (
+ <div className="flex justify-center space-x-2">
+ <AnimatePresence mode="wait">
+ {word.split("").map((char, i) => (
+ <motion.span
+ key={i}
+ initial="hidden"
+ animate="visible"
+ exit="hidden"
+ variants={framerProps}
+ transition={{ duration, delay: i * delayMultiple }}
+ className={cn("origin-center drop-shadow-sm", className)}
+ >
+ {char}
+ </motion.span>
+ ))}
+ </AnimatePresence>
+ </div>
+ );
+}
diff --git a/registry/index.tsx b/registry/index.tsx
index 57a4585f..4c424170 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -177,6 +177,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/letter-pullup.tsx"],
},
+ "flip-text": {
+ name: "flip-text",
+ type: "components:ui",
+ files: ["registry/components/magicui/flip-text.tsx"],
+ },
};
const example: Registry = {
@@ -664,6 +669,14 @@ const example: Registry = {
() => import("@/registry/components/example/letter-pullup-demo"),
),
},
+ "flip-text-demo": {
+ name: "flip-text-demo",
+ type: "components:example",
+ files: ["registry/components/example/flip-text-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/flip-text-demo"),
+ ),
+ },
};
export const registry: Registry = {