my/ui

Command Palette

Search for a command to run...

All components

Animated Shiny Text

text

A light glare effect which pans across text making it appear as if it is shimmering.

responsive · 320px

Install

Same command in any shadcn project — React (Vite/CRA), Next.js, Remix, Astro, and more:

$npx shadcn@latest add https://your-domain/r/animated-shiny-text.json

Usage

import { AnimatedShinyText } from "@/registry/magic-ui/animated-shiny-text";

export default function Demo() {
  return (
    <div className="flex items-center justify-center w-full p-8">
      <AnimatedShinyText className="text-2xl font-semibold">
        ✦ Introducing Magic UI — beautifully crafted components.
      </AnimatedShinyText>
    </div>
  );
}

Component source

import {
  type ComponentPropsWithoutRef,
  type CSSProperties,
  type FC,
} from "react"

import { cn } from "@/lib/utils"

export interface AnimatedShinyTextProps extends ComponentPropsWithoutRef<"span"> {
  shimmerWidth?: number
}

export const AnimatedShinyText: FC<AnimatedShinyTextProps> = ({
  children,
  className,
  shimmerWidth = 100,
  ...props
}) => {
  return (
    <span
      style={
        {
          "--shiny-width": `${shimmerWidth}px`,
        } as CSSProperties
      }
      className={cn(
        "mx-auto max-w-md text-neutral-600/70 dark:text-neutral-400/70",

        // Shine effect
        "animate-shiny-text bg-size-[var(--shiny-width)_100%] bg-clip-text bg-position-[0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]",

        // Shine gradient
        "bg-linear-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80",

        className
      )}
      {...props}
    >
      {children}
    </span>
  )
}

Source: Magic UI