UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: Add shimmer text component
Dillion Verma330b3aba3f9a
diff --git a/content/components/text-shimmer.mdx b/content/components/text-shimmer.mdxnew file mode 100644index 00000000..fd9e2369--- /dev/null+++ b/content/components/text-shimmer.mdx@@ -0,0 +1,69 @@+---+title: Text Shimmer+date: 2024-01-16+summary: A light glare effect which pans across text making it appear as if it is shimmering.+author: dillionverma+published: false+video: https://cdn.magicui.design/text-shimmer.mp4+---++<ComponentPreview name="text-shimmer-demo" />++<Steps>++<Step>++## Prerequisites++```bash+npm install -D tailwindcss clsx+```++```js+// tailwind.config.js+module.exports = {+ theme: {+ extend: {+ animation: {+ shimmer: "shimmer 8s infinite",+ },+ keyframes: {+ shimmer: {+ "0%, 90%, 100%": {+ "background-position": "calc(-100% - var(--shimmer-width)) 0",+ },+ "30%, 60%": {+ "background-position": "calc(100% + var(--shimmer-width)) 0",+ },+ },+ },+ },+ },+};+```++</Step>++<Step>++## Installation++Copy and paste the following code into your project.++```text+components/magicui/text-shimmer.tsx+```++<ComponentSource name="text-shimmer" />++</Step>++</Steps>++## Props++| Prop | Type | Description | Default |+| ------------ | ------ | -------------------------------------------- | ------- |+| children | | The text to be shimmered. | |+| className | string | The class name to be applied to the shimmer. | |+| shimmerWidth | number | The width of the shimmer in pixels. | 100 |diff --git a/registry/components/example/text-shimmer-demo.tsx b/registry/components/example/text-shimmer-demo.tsxnew file mode 100644index 00000000..7a16a217--- /dev/null+++ b/registry/components/example/text-shimmer-demo.tsx@@ -0,0 +1,11 @@+import TextShimmer from "@/registry/components/magicui/text-shimmer";++export default async function TextShimmerDemo() {+ return (+ <div className="relative flex h-full w-full max-w-[32rem] items-center justify-center overflow-hidden rounded-lg border bg-background p-8 shadow-2xl">+ <TextShimmer className="text-center text-5xl font-semibold leading-none">+ Text Shimmer+ </TextShimmer>+ </div>+ );+}diff --git a/registry/components/magicui/text-shimmer.tsx b/registry/components/magicui/text-shimmer.tsxnew file mode 100644index 00000000..71f834d9--- /dev/null+++ b/registry/components/magicui/text-shimmer.tsx@@ -0,0 +1,39 @@+import { cn } from "@/lib/utils";+import { CSSProperties, FC, ReactNode } from "react";++interface TextShimmerProps {+ children: ReactNode;+ className?: string;+ shimmerWidth?: number;+}++const TextShimmer: FC<TextShimmerProps> = ({+ children,+ className,+ shimmerWidth = 100,+}) => {+ return (+ <p+ style={+ {+ "--shimmer-width": `${shimmerWidth}px`,+ } as CSSProperties+ }+ className={cn(+ "mx-auto max-w-md text-neutral-400/50 dark:text-neutral-600/50",++ // Shimmer effect+ "animate-shimmer bg-clip-text bg-no-repeat [background-position:0_0] [background-size:var(--shimmer-width)_100%] [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]",++ // Shimmer gradient+ "bg-gradient-to-r from-neutral-100 via-black via-50% to-neutral-100 dark:from-neutral-900 dark:via-white/80 dark:to-neutral-900",++ className,+ )}+ >+ {children}+ </p>+ );+};++export default TextShimmer;diff --git a/registry/index.tsx b/registry/index.tsxindex 0f8cb17a..88ccb31b 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -92,6 +92,16 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/animated-list.tsx"],},+ "animated-lines": {+ name: "animated-lines",+ type: "components:ui",+ files: ["registry/components/magicui/animated-lines.tsx"],+ },+ "text-shimmer": {+ name: "text-shimmer",+ type: "components:ui",+ files: ["registry/components/magicui/text-shimmer.tsx"],+ },};const example: Registry = {@@ -312,6 +322,22 @@ const example: Registry = {() => import("@/registry/components/example/animated-list-demo"),),},+ "animated-lines-demo": {+ name: "animated-lines-demo",+ type: "components:example",+ files: ["registry/components/example/animated-lines-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/animated-lines-demo"),+ ),+ },+ "text-shimmer-demo": {+ name: "text-shimmer-demo",+ type: "components:example",+ files: ["registry/components/example/text-shimmer-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/text-shimmer-demo"),+ ),+ },};export const registry: Registry = {diff --git a/tailwind.config.ts b/tailwind.config.tsindex 515c821d..65016705 100644--- a/tailwind.config.ts+++ b/tailwind.config.ts@@ -72,6 +72,8 @@ module.exports = {spin: "spin calc(var(--speed) * 2) infinite linear",slide: "slide var(--speed) ease-in-out infinite alternate",ripple: "ripple 3400ms ease infinite",+ line: "line 2s linear infinite",+ shimmer: "shimmer 8s infinite",},keyframes: {"accordion-down": {@@ -142,6 +144,18 @@ module.exports = {transform: "translate(calc(100cqw - 100%), 0)",},},+ line: {+ "0%": { "mask-position-x": "0%" },+ "100%": { "mask-position-x": "100%" },+ },+ shimmer: {+ "0%, 90%, 100%": {+ "background-position": "calc(-100% - var(--shimmer-width)) 0",+ },+ "30%, 60%": {+ "background-position": "calc(100% + var(--shimmer-width)) 0",+ },+ },},},},