# Dia Text Reveal

- Page: https://jiguang132.com/resources/magic-ui/docs/dia-text-reveal
- Resource: Magic UI (https://jiguang132.com/resources/magic-ui.md)
- All guides: https://jiguang132.com/resources/magic-ui/docs.md

Install: `npx shadcn@latest add https://jiguang132.com/r/magic-ui/dia-text-reveal.json`

## Use case

Reveal text diagonally using layered colored clips.

## Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

| Owning component prop | Explanation | Example source |
| --- | --- | --- |
| `DiaTextReveal.className` (dia-text-reveal) | Classes on this native component; initialize Tailwind and its required CSS first. | `examples/dia-text-reveal-demo.tsx`、`examples/dia-text-reveal-demo-2.tsx`、`examples/dia-text-reveal-demo-4.tsx` |
| `DiaTextReveal.text` (dia-text-reveal) | Text supplied by the host, not generated by this effect. | `examples/dia-text-reveal-demo.tsx`、`examples/dia-text-reveal-demo-2.tsx`、`examples/dia-text-reveal-demo-3.tsx`、`examples/dia-text-reveal-demo-4.tsx` |
| `DiaTextReveal.colors` (dia-text-reveal) | The owning effect's native color list/object; keep its actual structure. | `examples/dia-text-reveal-demo.tsx`、`examples/dia-text-reveal-demo-2.tsx`、`examples/dia-text-reveal-demo-4.tsx` |
| `DiaTextReveal.repeat` (dia-text-reveal) | Native repeat behavior; boolean in DiaTextReveal, not Marquee's content count. | `examples/dia-text-reveal-demo-3.tsx` |
| `DiaTextReveal.repeatDelay` (dia-text-reveal) | Delay between repeats; retain the owner's numeric time unit. | `examples/dia-text-reveal-demo-3.tsx` |
| `DiaTextReveal.delay` (dia-text-reveal) | Native start delay; Motion seconds versus typing/terminal milliseconds must not be mixed. | `examples/dia-text-reveal-demo-4.tsx` |
| `DiaTextReveal.duration` (dia-text-reveal) | Native animation duration; numeric/CSS units differ by owner, see source defaults. | `examples/dia-text-reveal-demo-4.tsx` |

## Interaction and state checks

- Dia Text Reveal Demo — `dia-text-reveal-demo`
- Dia Text Reveal Demo 2 — `dia-text-reveal-demo-2`
- Dia Text Reveal Demo 3 — `dia-text-reveal-demo-3`
- Dia Text Reveal Demo 4 — `dia-text-reveal-demo-4`

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

## Business integration boundary

text and colors are display inputs; repeat and timing do not represent a loading lifecycle.

## Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.


## Available examples

dia-text-reveal-demo, dia-text-reveal-demo-2, dia-text-reveal-demo-3, dia-text-reveal-demo-4

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.




## Examples

### Custom gradient

Override `colors` for a shorter or softer palette on a single line of text.



### Rotating phrases in a heading

Pass `text` as an array and set `repeat` to cycle strings after each sweep. You can place static words in the same `<h1>` (or paragraph) before the component—no extra layout wrappers are required for basic inline use.



Use `fixedWidth` when the strings differ a lot in length and you want to avoid horizontal layout shift (not shown in this example).

### Duration and delay

Slow the sweep with `duration`, or add a short `delay` before the band moves.



## 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/dia-text-reveal
```

</TabsContent>

<TabsContent value="manual">

<Steps>

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



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

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx showLineNumbers
import { DiaTextReveal } from "@/components/ui/dia-text-reveal"
```

```tsx showLineNumbers
<DiaTextReveal text="Magic UI" />
```

```tsx showLineNumbers
<h1 className="text-3xl font-semibold">
  Learn to{" "}
  <DiaTextReveal
    repeat
    repeatDelay={1.2}
    text={["build faster", "ship smarter", "scale easier"]}
  />
</h1>
```

## Props

| Prop          | Type                 | Default                                                   | Description                                                                     |
| ------------- | -------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `text`        | `string \| string[]` | —                                                         | Text to display. Use an array to rotate between strings when `repeat` is on.    |
| `colors`      | `string[]`           | `["#c679c4", "#fa3d1d", "#ffb005", "#e1e1fe", "#0358f7"]` | Colors in the sweeping gradient band.                                           |
| `textColor`   | `string`             | `var(--foreground)`                                       | Solid text color after the animation (matches your theme by default).           |
| `duration`    | `number`             | `1.5`                                                     | Sweep duration in seconds.                                                      |
| `delay`       | `number`             | `0`                                                       | Delay before the sweep starts, in seconds.                                      |
| `repeat`      | `boolean`            | `false`                                                   | When `text` is an array, advance to the next string after each cycle.           |
| `repeatDelay` | `number`             | `0.5`                                                     | Pause in seconds before replaying or advancing (when `repeat` is true).         |
| `startOnView` | `boolean`            | `true`                                                    | Start the animation when the element enters the viewport.                       |
| `once`        | `boolean`            | `true`                                                    | Play only the first time (when `startOnView` is used).                          |
| `className`   | `string`             | —                                                         | Additional CSS classes on the root `span`.                                      |
| `fixedWidth`  | `boolean`            | `false`                                                   | Lock width to the widest string when `text` is an array to reduce layout shift. |

## Credits

- Credit to [@chishiyac](https://github.com/chishiyac)




## Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

### Dia Text Reveal Demo

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dia-text-reveal/dia-text-reveal-demo.json
```

Default import: `@/components/magicui/examples/dia-text-reveal-demo`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Dia Text Reveal Demo 2

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dia-text-reveal/dia-text-reveal-demo-2.json
```

Default import: `@/components/magicui/examples/dia-text-reveal-demo-2`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Dia Text Reveal Demo 3

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dia-text-reveal/dia-text-reveal-demo-3.json
```

Default import: `@/components/magicui/examples/dia-text-reveal-demo-3`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Dia Text Reveal Demo 4

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dia-text-reveal/dia-text-reveal-demo-4.json
```

Default import: `@/components/magicui/examples/dia-text-reveal-demo-4`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Minimal usage and theme

```tsx
import Demo from '@/components/magicui/examples/dia-text-reveal-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

```

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.


## Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.


```ts
DiaTextReveal({
  text,
  colors = DEFAULT_COLORS,
  textColor = "var(--foreground)",
  duration = 1.5,
  delay = 0,
  repeat = false,
  repeatDelay = 0.5,
  startOnView = true,
  once = true,
  className,
  fixedWidth = false,
  ...props
}: DiaTextRevealProps)
```



```ts
export interface DiaTextRevealProps extends Omit<
  HTMLMotionProps<"span">,
  "ref" | "children" | "style" | "animate" | "transition" | "color"
> {
  /**
   * Text to reveal. Pass multiple strings to rotate when {@link DiaTextRevealProps.repeat} is `true`.
   */
  text: string | string[]
  /**
   * Colors sampled across the moving gradient band. Defaults to a built-in palette.
   */
  colors?: string[]
  /**
   * CSS color for revealed text after the sweep and for leading/trailing regions during the animation.
   * @defaultValue `"var(--foreground)"`
   */
  textColor?: string
  /**
   * Duration of one sweep pass, in seconds.
   * @defaultValue `1.5`
   */
  duration?: number
  /**
   * Delay before the sweep starts, in seconds.
   * @defaultValue `0`
   */
  delay?: number
  /**
   * When `text` is an array, replay the sweep and advance to the next string after each completion.
   * @defaultValue `false`
   */
  repeat?: boolean
  /**
   * Pause between cycles when {@link DiaTextRevealProps.repeat} is `true`, in seconds.
   * @defaultValue `0.5`
   */
  repeatDelay?: number
  /**
   * If `true`, the animation starts only after the element enters the viewport.
   * @defaultValue `true`
   */
  startOnView?: boolean
  /**
   * Passed to `useInView`: if `true`, in-view detection fires at most once (no replay on scroll-back).
   * @defaultValue `true`
   */
  once?: boolean
  /**
   * Additional class names for the animated `span` (e.g. typography utilities).
   */
  className?: string
  /**
   * When `text` has multiple entries, use the widest string’s width for layout instead of animating width per line.
   * @defaultValue `false`
   */
  fixedWidth?: boolean
}
```


### Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.


```ts
// DiaTextReveal
colors = DEFAULT_COLORS

// DiaTextReveal
textColor = "var(--foreground)"

// DiaTextReveal
duration = 1.5

// DiaTextReveal
delay = 0

// DiaTextReveal
repeat = false

// DiaTextReveal
repeatDelay = 0.5

// DiaTextReveal
startOnView = true

// DiaTextReveal
once = true

// DiaTextReveal
fixedWidth = false
```


### Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.


```ts
Omit<
  HTMLMotionProps<"span">,
  "ref" | "children" | "style" | "animate" | "transition" | "color"
>
HTMLMotionProps<"span">
```

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
