Skip to content

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

1.9 KB
Raw Blame
---
title: Animated Shiny Text
date: 2024-01-16
description: A light glare effect which pans across text making it appear as if it is shimmering.
author: dillionverma
published: true
video: https://cdn.magicui.design/animated-shiny-text.mp4
---

<ComponentPreview name="animated-shiny-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/animated-shiny-text
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="animated-shiny-text" />

<Step>Update the import paths to match your project setup.</Step>

<Step>Add the required CSS animations</Step>

Add the following animations to your global CSS file.

```css title="app/globals.css" showLineNumbers {2, 4-14}
@theme inline {
  --animate-shiny-text: shiny-text 8s infinite;

  @keyframes shiny-text {
    0%,
    90%,
    100% {
      background-position: calc(-100% - var(--shiny-width)) 0;
    }
    30%,
    60% {
      background-position: calc(100% + var(--shiny-width)) 0;
    }
  }
}
```

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx showLineNumbers
import { AnimatedShinyText } from "@/components/ui/animated-shiny-text"
```

```tsx showLineNumbers
<AnimatedShinyText>Hello</AnimatedShinyText>
```

## Props

| Prop           | Type     | Default | Description                                  |
| -------------- | -------- | ------- | -------------------------------------------- |
| `children`     | `node`   | `-`     | The text to be shimmered.                    |
| `className`    | `string` | `-`     | The class name to be applied to the shimmer. |
| `shimmerWidth` | `number` | `100`   | The width of the shimmer in pixels.          |