my/ui

Command Palette

Search for a command to run...

All components

Aurora Text

text

A beautiful aurora text effect

responsive · 360px

Install

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

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

Usage

import { AuroraText } from "@/registry/magic-ui/aurora-text";

export default function Demo() {
  return (
    <div className="flex items-center justify-center w-full p-8">
      <h1 className="text-5xl font-bold">
        Build{" "}
        <AuroraText>beautiful</AuroraText>
        {" "}apps.
      </h1>
    </div>
  );
}

Component source

"use client"

import React, { memo } from "react"

interface AuroraTextProps {
  children: React.ReactNode
  className?: string
  colors?: string[]
  speed?: number
}

export const AuroraText = memo(
  ({
    children,
    className = "",
    colors = ["#FF0080", "#7928CA", "#0070F3", "#38bdf8"],
    speed = 1,
  }: AuroraTextProps) => {
    const gradientStyle = {
      backgroundImage: `linear-gradient(135deg, ${colors.join(", ")}, ${
        colors[0]
      })`,
      WebkitBackgroundClip: "text",
      WebkitTextFillColor: "transparent",
      animationDuration: `${10 / speed}s`,
    }

    return (
      <span className={`relative inline-block ${className}`}>
        <span className="sr-only">{children}</span>
        <span
          className="animate-aurora relative bg-size-[200%_auto] bg-clip-text text-transparent"
          style={gradientStyle}
          aria-hidden="true"
        >
          {children}
        </span>
      </span>
    )
  }
)

AuroraText.displayName = "AuroraText"

Source: Magic UI