UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
feat: line shadow text component added (#501)
Arghya Das74a6255a7c7a
diff --git a/__registry__/index.tsx b/__registry__/index.tsxindex 8446242e..5dc33163 100644--- a/__registry__/index.tsx+++ b/__registry__/index.tsx@@ -44,6 +44,19 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: [],},+ "line-shadow-text": {+ name: "line-shadow-text",+ type: "registry:ui",+ registryDependencies: undefined,+ files: ["registry/default/magicui/line-shadow-text.tsx"],+ component: React.lazy(+ () => import("@/registry/default/magicui/line-shadow-text.tsx"),+ ),+ source: "",+ category: "undefined",+ subcategory: "undefined",+ chunks: [],+ },"morphing-text": {name: "morphing-text",type: "registry:ui",@@ -828,6 +841,19 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: [],},+ "line-shadow-text-demo": {+ name: "line-shadow-text-demo",+ type: "registry:example",+ registryDependencies: ["line-shadow-text"],+ files: ["registry/default/example/line-shadow-text-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/default/example/line-shadow-text-demo.tsx"),+ ),+ source: "",+ category: "undefined",+ subcategory: "undefined",+ chunks: [],+ },"morphing-text-demo": {name: "morphing-text-demo",type: "registry:example",diff --git a/config/docs.ts b/config/docs.tsindex 368341f1..c22aa394 100644--- a/config/docs.ts+++ b/config/docs.ts@@ -319,6 +319,12 @@ export const docsConfig: DocsConfig = {items: [],label: "New",},+ {+ title: "Line Shadow Text",+ href: `/docs/components/line-shadow-text`,+ items: [],+ label: "New",+ },{title: "Number Ticker",href: `/docs/components/number-ticker`,diff --git a/content/docs/components/line-shadow-text.mdx b/content/docs/components/line-shadow-text.mdxnew file mode 100644index 00000000..da3a0d59--- /dev/null+++ b/content/docs/components/line-shadow-text.mdx@@ -0,0 +1,72 @@+---+title: Line Shadow Text+date: 2025-01-11+description: A line shadow text component for Magic UI+author: magicui+published: true+---++<ComponentPreview name="line-shadow-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 "https://magicui.design/r/line-shadow-text"+```++</TabsContent>++<TabsContent value="manual">++<Steps>++<Step>Copy and paste the following code into your project.</Step>++<ComponentSource name="line-shadow-text" />++<Step>Update the import paths to match your project setup.</Step>++<Step>Update `tailwind.config.js`</Step>++Add the following animations to your `tailwind.config.js` file:++```js title="tailwind.config.js" {5-13}+/** @type {import('tailwindcss').Config} */+module.exports = {+ theme: {+ extend: {+ animation: {+ "line-shadow": "line-shadow 15s linear infinite",+ },+ keyframes: {+ "line-shadow": {+ "0%": { "background-position": "0 0" },+ "100%": { "background-position": "100% -100%" },+ },+ },+ },+ },+};+```++</Steps>++</TabsContent>++</Tabs>++## Props++| Prop | Type | Default | Description |+| ----------- | ------ | --------- | -------------------------------------- |+| shadowColor | string | `"black"` | The color of the shadow effect |+| children | string | - | The text to display with shadow effect |+| as | string | `"span"` | The HTML element to render the text as |diff --git a/public/r/index.json b/public/r/index.jsonindex e15900a8..1907f5d1 100644--- a/public/r/index.json+++ b/public/r/index.json@@ -35,6 +35,16 @@}]},+ {+ "name": "line-shadow-text",+ "type": "registry:ui",+ "files": [+ {+ "path": "magicui/line-shadow-text.tsx",+ "type": "registry:ui"+ }+ ]+ },{"name": "morphing-text","type": "registry:ui",diff --git a/public/r/styles/default/line-shadow-text.json b/public/r/styles/default/line-shadow-text.jsonnew file mode 100644index 00000000..30e74120--- /dev/null+++ b/public/r/styles/default/line-shadow-text.json@@ -0,0 +1,12 @@+{+ "name": "line-shadow-text",+ "type": "registry:ui",+ "files": [+ {+ "path": "magicui/line-shadow-text.tsx",+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport function LineShadowText({\n text = \"SHADOW\",\n shadowColor = \"black\",\n className,\n}: {\n text?: string;\n shadowColor?: string;\n className?: string;\n}) {\n return (\n <span\n style={{ \"--shadow-color\": shadowColor } as React.CSSProperties}\n className={cn(\n \"relative inline-flex\",\n\n // positioning\n \"after:absolute after:left-[0.04em] after:top-[0.04em] after:content-[attr(data-text)]\",\n\n // color\n \"after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]\",\n\n // text\n \"after:bg-[length:0.06em_0.06em] after:bg-clip-text after:text-transparent\",\n\n // animation\n \"after:animate-line-shadow\",\n\n className,\n )}\n data-text={text}\n >\n {text}\n </span>\n );\n}\n",+ "type": "registry:ui",+ "target": ""+ }+ ]+}\ No newline at end of filediff --git a/registry/default/example/line-shadow-text-demo.tsx b/registry/default/example/line-shadow-text-demo.tsxnew file mode 100644index 00000000..f9b15e72--- /dev/null+++ b/registry/default/example/line-shadow-text-demo.tsx@@ -0,0 +1,15 @@+import { LineShadowText } from "@/registry/default/magicui/line-shadow-text";+import { useTheme } from "next-themes";++export default function LineShadowTextDemo() {+ const theme = useTheme();+ const shadowColor = theme.resolvedTheme === "dark" ? "white" : "black";+ return (+ <h1 className="text-balance text-5xl font-semibold leading-none tracking-tighter sm:text-6xl md:text-7xl lg:text-8xl">+ Ship+ <LineShadowText className="italic" shadowColor={shadowColor}>+ Fast+ </LineShadowText>+ </h1>+ );+}diff --git a/registry/default/magicui/line-shadow-text.tsx b/registry/default/magicui/line-shadow-text.tsxnew file mode 100644index 00000000..179d805e--- /dev/null+++ b/registry/default/magicui/line-shadow-text.tsx@@ -0,0 +1,42 @@+import { cn } from "@/lib/utils";+import { motion, MotionProps } from "motion/react";++interface LineShadowTextProps+ extends Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps>,+ MotionProps {+ shadowColor?: string;+ as?: React.ElementType;+}++export function LineShadowText({+ children,+ shadowColor = "black",+ className,+ as: Component = "span",+ ...props+}: LineShadowTextProps) {+ const MotionComponent = motion.create(Component);+ const content = typeof children === "string" ? children : null;++ if (!content) {+ throw new Error("LineShadowText only accepts string content");+ }++ return (+ <MotionComponent+ style={{ "--shadow-color": shadowColor } as React.CSSProperties}+ className={cn(+ "relative z-0 inline-flex",+ "after:absolute after:left-[0.04em] after:top-[0.04em] after:content-[attr(data-text)]",+ "after:bg-[linear-gradient(45deg,transparent_45%,var(--shadow-color)_45%,var(--shadow-color)_55%,transparent_0)]",+ "after:-z-10 after:bg-[length:0.06em_0.06em] after:bg-clip-text after:text-transparent",+ "after:animate-line-shadow",+ className,+ )}+ data-text={content}+ {...props}+ >+ {content}+ </MotionComponent>+ );+}diff --git a/registry/registry-examples.ts b/registry/registry-examples.tsindex e55fcef5..065cbff9 100644--- a/registry/registry-examples.ts+++ b/registry/registry-examples.ts@@ -31,6 +31,12 @@ export const examples: Registry = [registryDependencies: ["warp-background"],files: ["example/warp-background-demo.tsx"],},+ {+ name: "line-shadow-text-demo",+ type: "registry:example",+ registryDependencies: ["line-shadow-text"],+ files: ["example/line-shadow-text-demo.tsx"],+ },{name: "morphing-text-demo",type: "registry:example",diff --git a/registry/registry-ui.ts b/registry/registry-ui.tsindex 7c5ca4ca..d651c91b 100644--- a/registry/registry-ui.ts+++ b/registry/registry-ui.ts@@ -18,6 +18,12 @@ export const ui: Registry = [dependencies: ["motion"],files: ["magicui/warp-background.tsx"],},+ {+ name: "line-shadow-text",+ type: "registry:ui",+ dependencies: ["motion"],+ files: ["magicui/line-shadow-text.tsx"],+ },{name: "morphing-text",type: "registry:ui",diff --git a/tailwind.config.cjs b/tailwind.config.cjsindex e16f9e6e..ea12c0cc 100644--- a/tailwind.config.cjs+++ b/tailwind.config.cjs@@ -86,6 +86,7 @@ module.exports = {shine: "shine var(--duration) infinite linear",pulse: "pulse var(--duration) ease-out infinite",rainbow: "rainbow var(--speed, 2s) infinite linear",+ "line-shadow": "line-shadow 15s linear infinite",},keyframes: {"accordion-down": {@@ -207,6 +208,10 @@ module.exports = {"0%": { "background-position": "0%" },"100%": { "background-position": "200%" },},+ "line-shadow": {+ "0%": { "background-position": "0 0" },+ "100%": { "background-position": "100% -100%" },+ },},},},