Skip to content

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

feat: add kinetic-text component (#955)

Abdimajidcb478c0b13b1
diff --git a/apps/www/config/docs.ts b/apps/www/config/docs.ts
index 0b84cab0..92df2797 100644
--- a/apps/www/config/docs.ts
+++ b/apps/www/config/docs.ts
@@ -603,6 +603,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "",
},
+ {
+ title: "Kinetic Text",
+ href: `/docs/components/kinetic-text`,
+ items: [],
+ label: "New",
+ },
{
title: "Cool Mode",
href: `/docs/components/cool-mode`,
diff --git a/apps/www/content/docs/components/kinetic-text.mdx b/apps/www/content/docs/components/kinetic-text.mdx
new file mode 100644
index 00000000..8c86ebc1
--- /dev/null
+++ b/apps/www/content/docs/components/kinetic-text.mdx
@@ -0,0 +1,63 @@
+---
+title: Kinetic Text
+date: 2026-04-20
+description: A text component that animates font weight of characters on hover.
+author: abdmjd1
+published: true
+---
+
+<ComponentPreview name="kinetic-text-demo" />
+
+## Installation
+
+<Tabs defaultValue="cli">
+
+<TabsList>
+ <TabsTrigger value="cli">CLI</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add @magicui/kinetic-text
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps>
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<ComponentSource name="kinetic-text" />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</Tabs>
+
+## Usage
+
+```tsx showLineNumbers
+import { KineticText } from "@/components/ui/kinetic-text"
+```
+
+```tsx showLineNumbers
+<KineticText text="some text" />
+```
+
+## Props
+
+| Prop | Type | Default | Description |
+| ----------- | --------------------------------------------------------------- | ------- | --------------------------------------------------- |
+| `text` | `string` | `-` | The text content to render with the kinetic effect. |
+| `as` | `"h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6" \| "p" \| "span"` | `"h1"` | The HTML element to render as. |
+| `className` | `string` | `-` | Additional class names for the wrapper element. |
+
+## Credits
+
+- Credit to [@abdmjd1](https://github.com/abdmjd1)
diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txt
index 832ba066..39bd644c 100644
--- a/apps/www/public/llms-full.txt
+++ b/apps/www/public/llms-full.txt
@@ -11005,6 +11005,75 @@ export default function Demo() {
+===== COMPONENT: kinetic-text =====
+Title: Kinetic Text
+Description: A text component that animates font weight of characters on hover.
+
+--- file: magicui/kinetic-text.tsx ---
+import React from "react"
+
+import { cn } from "@/lib/utils"
+
+type As = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span"
+
+type KineticTextProps = React.HTMLAttributes<HTMLElement> & {
+ text: string
+ as?: As
+}
+
+export function KineticText({
+ text,
+ as: Tag = "h1",
+ className = "",
+ style,
+ ...rest
+}: KineticTextProps) {
+ const mergedStyle = {
+ "--hover-padding": "calc(1em / 12)",
+ "--text-stroke-width": "calc(1em * 125 / 6000)",
+ ...(style as React.CSSProperties | undefined),
+ } as React.CSSProperties
+
+ return (
+ <Tag
+ {...rest}
+ className={cn("flex flex-wrap font-[300]", className)}
+ style={mergedStyle}
+ >
+ {text.split("").map((letter, i) => (
+ <span
+ key={i}
+ aria-hidden="true"
+ className="[will-change:font-weight,-webkit-text-stroke-width,padding] [-webkit-text-stroke-color:transparent] [-webkit-text-stroke-width:var(--text-stroke-width)] [transition:font-weight_0.4s,_-webkit-text-stroke-color_0.4s,_padding_0.4s] hover:[padding-inline:var(--hover-padding)] hover:font-[900] hover:[-webkit-text-stroke-color:currentcolor] hover:[-webkit-text-stroke-width:calc(var(--text-stroke-width)*2)] has-[+span+span:hover]:font-[400] has-[+span:hover]:[padding-inline:var(--hover-padding)] has-[+span:hover]:font-[600] [:hover+&]:[padding-inline:var(--hover-padding)] [:hover+&]:font-[600] [:hover+span+&]:font-[400]"
+ >
+ {letter === " " ? "\u00A0" : letter}
+ </span>
+ ))}
+ <span className="sr-only">{text}</span>
+ </Tag>
+ )
+}
+
+
+===== EXAMPLE: kinetic-text-demo =====
+Title: kinetic-text-demo
+
+--- file: example/kinetic-text-demo.tsx ---
+import { KineticText } from "@/registry/magicui/kinetic-text"
+
+export default function KineticTextDemo() {
+ return (
+ <div className="relative justify-center">
+ <KineticText
+ text="Nostalgia"
+ className="text-[6rem] tracking-[-5%] [font-optical-sizing:auto]"
+ />
+ </div>
+ )
+}
+
+
+
===== COMPONENT: lens =====
Title: Lens
Description: A interactive component that enables zooming into images, videos and other elements.
diff --git a/apps/www/public/llms.txt b/apps/www/public/llms.txt
index b572884e..034ca66e 100644
--- a/apps/www/public/llms.txt
+++ b/apps/www/public/llms.txt
@@ -42,6 +42,7 @@ This file provides LLM-friendly entry points to documentation and examples.
- [Interactive Grid Pattern](https://magicui.design/docs/components/interactive-grid-pattern): A interactive background grid pattern made with SVGs, fully customizable using Tailwind CSS.
- [interactive-hover-button](https://magicui.design/docs/components/interactive-hover-button): The interactive-hover-button component.
- [iPhone](https://magicui.design/docs/components/iphone): A mockup of the iPhone
+- [Kinetic Text](https://magicui.design/docs/components/kinetic-text): A text component that animates font weight of characters on hover.
- [Lens](https://magicui.design/docs/components/lens): A interactive component that enables zooming into images, videos and other elements.
- [Light Rays](https://magicui.design/docs/components/light-rays): A component with animated light rays which shine down from above.
- [Line Shadow Text](https://magicui.design/docs/components/line-shadow-text): A text component with a moving line shadow.
@@ -247,6 +248,7 @@ This file provides LLM-friendly entry points to documentation and examples.
- [backlight-video-demo](https://github.com/magicuidesign/magicui/blob/main/example/backlight-video-demo.tsx): Example usage
- [backlight-image-demo](https://github.com/magicuidesign/magicui/blob/main/example/backlight-image-demo.tsx): Example usage
- [backlight-svg-demo](https://github.com/magicuidesign/magicui/blob/main/example/backlight-svg-demo.tsx): Example usage
+- [kinetic-text-demo](https://github.com/magicuidesign/magicui/blob/main/example/kinetic-text-demo.tsx): Example usage
- [Text 3D Flip Demo](https://github.com/magicuidesign/magicui/blob/main/example/text-3d-flip-demo.tsx): Example usage
- [Text 3D Flip Demo 2](https://github.com/magicuidesign/magicui/blob/main/example/text-3d-flip-demo-2.tsx): Example usage
diff --git a/apps/www/public/r/kinetic-text-demo.json b/apps/www/public/r/kinetic-text-demo.json
new file mode 100644
index 00000000..73f3c1e7
--- /dev/null
+++ b/apps/www/public/r/kinetic-text-demo.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "kinetic-text-demo",
+ "type": "registry:example",
+ "description": "An example of the kinetic text component.",
+ "registryDependencies": [
+ "@magicui/kinetic-text"
+ ],
+ "files": [
+ {
+ "path": "registry/example/kinetic-text-demo.tsx",
+ "content": "import { KineticText } from \"@/registry/magicui/kinetic-text\"\n\nexport default function KineticTextDemo() {\n return (\n <div className=\"relative justify-center\">\n <KineticText\n text=\"Nostalgia\"\n className=\"text-[6rem] tracking-[-5%] [font-optical-sizing:auto]\"\n />\n </div>\n )\n}\n",
+ "type": "registry:example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/kinetic-text.json b/apps/www/public/r/kinetic-text.json
new file mode 100644
index 00000000..c2b338f9
--- /dev/null
+++ b/apps/www/public/r/kinetic-text.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "kinetic-text",
+ "type": "registry:ui",
+ "title": "Kinetic Text",
+ "description": "A text component that animates font weight of characters on hover.",
+ "dependencies": [],
+ "files": [
+ {
+ "path": "registry/magicui/kinetic-text.tsx",
+ "content": "import React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype As = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"p\" | \"span\"\n\ntype KineticTextProps = React.HTMLAttributes<HTMLElement> & {\n text: string\n as?: As\n}\n\nexport function KineticText({\n text,\n as: Tag = \"h1\",\n className = \"\",\n style,\n ...rest\n}: KineticTextProps) {\n const mergedStyle = {\n \"--hover-padding\": \"calc(1em / 12)\",\n \"--text-stroke-width\": \"calc(1em * 125 / 6000)\",\n ...(style as React.CSSProperties | undefined),\n } as React.CSSProperties\n\n return (\n <Tag\n {...rest}\n className={cn(\"flex flex-wrap font-[300]\", className)}\n style={mergedStyle}\n >\n {text.split(\"\").map((letter, i) => (\n <span\n key={i}\n aria-hidden=\"true\"\n className=\"[will-change:font-weight,-webkit-text-stroke-width,padding] [-webkit-text-stroke-color:transparent] [-webkit-text-stroke-width:var(--text-stroke-width)] [transition:font-weight_0.4s,_-webkit-text-stroke-color_0.4s,_padding_0.4s] hover:[padding-inline:var(--hover-padding)] hover:font-[900] hover:[-webkit-text-stroke-color:currentcolor] hover:[-webkit-text-stroke-width:calc(var(--text-stroke-width)*2)] has-[+span+span:hover]:font-[400] has-[+span:hover]:[padding-inline:var(--hover-padding)] has-[+span:hover]:font-[600] [:hover+&]:[padding-inline:var(--hover-padding)] [:hover+&]:font-[600] [:hover+span+&]:font-[400]\"\n >\n {letter === \" \" ? \"\\u00A0\" : letter}\n </span>\n ))}\n <span className=\"sr-only\">{text}</span>\n </Tag>\n )\n}\n",
+ "type": "registry:ui"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/www/public/r/registry.json b/apps/www/public/r/registry.json
index 94bdd805..fa8ff0eb 100644
--- a/apps/www/public/r/registry.json
+++ b/apps/www/public/r/registry.json
@@ -1320,6 +1320,19 @@
}
]
},
+ {
+ "name": "kinetic-text",
+ "type": "registry:ui",
+ "title": "Kinetic Text",
+ "description": "A text component that animates font weight of characters on hover.",
+ "dependencies": [],
+ "files": [
+ {
+ "path": "registry/magicui/kinetic-text.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "text-3d-flip",
"type": "registry:ui",
@@ -3845,6 +3858,20 @@
}
]
},
+ {
+ "name": "kinetic-text-demo",
+ "type": "registry:example",
+ "description": "An example of the kinetic text component.",
+ "registryDependencies": [
+ "@magicui/kinetic-text"
+ ],
+ "files": [
+ {
+ "path": "registry/example/kinetic-text-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "text-3d-flip-demo",
"type": "registry:example",
diff --git a/apps/www/public/registry.json b/apps/www/public/registry.json
index 94bdd805..fa8ff0eb 100644
--- a/apps/www/public/registry.json
+++ b/apps/www/public/registry.json
@@ -1320,6 +1320,19 @@
}
]
},
+ {
+ "name": "kinetic-text",
+ "type": "registry:ui",
+ "title": "Kinetic Text",
+ "description": "A text component that animates font weight of characters on hover.",
+ "dependencies": [],
+ "files": [
+ {
+ "path": "registry/magicui/kinetic-text.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "text-3d-flip",
"type": "registry:ui",
@@ -3845,6 +3858,20 @@
}
]
},
+ {
+ "name": "kinetic-text-demo",
+ "type": "registry:example",
+ "description": "An example of the kinetic text component.",
+ "registryDependencies": [
+ "@magicui/kinetic-text"
+ ],
+ "files": [
+ {
+ "path": "registry/example/kinetic-text-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "text-3d-flip-demo",
"type": "registry:example",
diff --git a/apps/www/registry.json b/apps/www/registry.json
index 94bdd805..fa8ff0eb 100644
--- a/apps/www/registry.json
+++ b/apps/www/registry.json
@@ -1320,6 +1320,19 @@
}
]
},
+ {
+ "name": "kinetic-text",
+ "type": "registry:ui",
+ "title": "Kinetic Text",
+ "description": "A text component that animates font weight of characters on hover.",
+ "dependencies": [],
+ "files": [
+ {
+ "path": "registry/magicui/kinetic-text.tsx",
+ "type": "registry:ui"
+ }
+ ]
+ },
{
"name": "text-3d-flip",
"type": "registry:ui",
@@ -3845,6 +3858,20 @@
}
]
},
+ {
+ "name": "kinetic-text-demo",
+ "type": "registry:example",
+ "description": "An example of the kinetic text component.",
+ "registryDependencies": [
+ "@magicui/kinetic-text"
+ ],
+ "files": [
+ {
+ "path": "registry/example/kinetic-text-demo.tsx",
+ "type": "registry:example"
+ }
+ ]
+ },
{
"name": "text-3d-flip-demo",
"type": "registry:example",
diff --git a/apps/www/registry/__index__.tsx b/apps/www/registry/__index__.tsx
index f84b4092..c660e626 100644
--- a/apps/www/registry/__index__.tsx
+++ b/apps/www/registry/__index__.tsx
@@ -1273,6 +1273,23 @@ export const Index: Record<string, any> = {
}),
meta: undefined,
},
+ "kinetic-text": {
+ name: "kinetic-text",
+ description: "A text component that animates font weight of characters on hover.",
+ type: "registry:ui",
+ registryDependencies: undefined,
+ files: [{
+ path: "registry/magicui/kinetic-text.tsx",
+ type: "registry:ui",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/magicui/kinetic-text.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-3d-flip": {
name: "text-3d-flip",
description: "A text effect that flips each letter in 3D with a staggered animation on hover.",
@@ -4065,6 +4082,23 @@ export const Index: Record<string, any> = {
}),
meta: undefined,
},
+ "kinetic-text-demo": {
+ name: "kinetic-text-demo",
+ description: "An example of the kinetic text component.",
+ type: "registry:example",
+ registryDependencies: ["@magicui/kinetic-text"],
+ files: [{
+ path: "registry/example/kinetic-text-demo.tsx",
+ type: "registry:example",
+ target: ""
+ }],
+ component: React.lazy(async () => {
+ const mod = await import("@/registry/example/kinetic-text-demo.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-3d-flip-demo": {
name: "text-3d-flip-demo",
description: "Example showing a 3D text animation that rotates each letter on hover.",
diff --git a/apps/www/registry/example/kinetic-text-demo.tsx b/apps/www/registry/example/kinetic-text-demo.tsx
new file mode 100644
index 00000000..78981344
--- /dev/null
+++ b/apps/www/registry/example/kinetic-text-demo.tsx
@@ -0,0 +1,12 @@
+import { KineticText } from "@/registry/magicui/kinetic-text"
+
+export default function KineticTextDemo() {
+ return (
+ <div className="relative justify-center">
+ <KineticText
+ text="Nostalgia"
+ className="text-[6rem] tracking-[-5%] [font-optical-sizing:auto]"
+ />
+ </div>
+ )
+}
diff --git a/apps/www/registry/magicui/kinetic-text.tsx b/apps/www/registry/magicui/kinetic-text.tsx
new file mode 100644
index 00000000..5c224a45
--- /dev/null
+++ b/apps/www/registry/magicui/kinetic-text.tsx
@@ -0,0 +1,43 @@
+import React from "react"
+
+import { cn } from "@/lib/utils"
+
+type As = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span"
+
+type KineticTextProps = React.HTMLAttributes<HTMLElement> & {
+ text: string
+ as?: As
+}
+
+export function KineticText({
+ text,
+ as: Tag = "h1",
+ className = "",
+ style,
+ ...rest
+}: KineticTextProps) {
+ const mergedStyle = {
+ "--hover-padding": "calc(1em / 12)",
+ "--text-stroke-width": "calc(1em * 125 / 6000)",
+ ...(style as React.CSSProperties | undefined),
+ } as React.CSSProperties
+
+ return (
+ <Tag
+ {...rest}
+ className={cn("flex flex-wrap font-[300]", className)}
+ style={mergedStyle}
+ >
+ {text.split("").map((letter, i) => (
+ <span
+ key={i}
+ aria-hidden="true"
+ className="[will-change:font-weight,-webkit-text-stroke-width,padding] [-webkit-text-stroke-color:transparent] [-webkit-text-stroke-width:var(--text-stroke-width)] [transition:font-weight_0.4s,_-webkit-text-stroke-color_0.4s,_padding_0.4s] hover:[padding-inline:var(--hover-padding)] hover:font-[900] hover:[-webkit-text-stroke-color:currentcolor] hover:[-webkit-text-stroke-width:calc(var(--text-stroke-width)*2)] has-[+span+span:hover]:font-[400] has-[+span:hover]:[padding-inline:var(--hover-padding)] has-[+span:hover]:font-[600] [:hover+&]:[padding-inline:var(--hover-padding)] [:hover+&]:font-[600] [:hover+span+&]:font-[400]"
+ >
+ {letter === " " ? "\u00A0" : letter}
+ </span>
+ ))}
+ <span className="sr-only">{text}</span>
+ </Tag>
+ )
+}
diff --git a/apps/www/registry/registry-examples.ts b/apps/www/registry/registry-examples.ts
index d3a5b3a2..9b88a274 100644
--- a/apps/www/registry/registry-examples.ts
+++ b/apps/www/registry/registry-examples.ts
@@ -2177,6 +2177,18 @@ export const examples: Registry["items"] = [
},
],
},
+ {
+ name: "kinetic-text-demo",
+ description: "An example of the kinetic text component.",
+ type: "registry:example",
+ registryDependencies: ["@magicui/kinetic-text"],
+ files: [
+ {
+ path: "example/kinetic-text-demo.tsx",
+ type: "registry:example",
+ },
+ ],
+ },
{
name: "text-3d-flip-demo",
type: "registry:example",
diff --git a/apps/www/registry/registry-ui.ts b/apps/www/registry/registry-ui.ts
index 2caf2513..873cf43e 100644
--- a/apps/www/registry/registry-ui.ts
+++ b/apps/www/registry/registry-ui.ts
@@ -1271,6 +1271,20 @@ export const ui: Registry["items"] = [
},
],
},
+ {
+ name: "kinetic-text",
+ type: "registry:ui",
+ title: "Kinetic Text",
+ description:
+ "A text component that animates font weight of characters on hover.",
+ dependencies: [],
+ files: [
+ {
+ path: "magicui/kinetic-text.tsx",
+ type: "registry:ui",
+ },
+ ],
+ },
{
name: "text-3d-flip",
type: "registry:ui",