JGuang

Dia Text Reveal

Dia Text Reveal · Magic UI

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

Some upstream demos use online images, videos or tweets. That content depends on network access and third-party services.

Dia Text Reveal

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 propExplanationExample 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">
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

import { DiaTextReveal } from "@/components/ui/dia-text-reveal"
<DiaTextReveal text="Magic UI" />
<h1 className="text-3xl font-semibold">
  Learn to{" "}
  <DiaTextReveal
    repeat
    repeatDelay={1.2}
    text={["build faster", "ship smarter", "scale easier"]}
  />
</h1>

Props

PropTypeDefaultDescription
textstring | string[]—Text to display. Use an array to rotate between strings when repeat is on.
colorsstring[]["#c679c4", "#fa3d1d", "#ffb005", "#e1e1fe", "#0358f7"]Colors in the sweeping gradient band.
textColorstringvar(--foreground)Solid text color after the animation (matches your theme by default).
durationnumber1.5Sweep duration in seconds.
delaynumber0Delay before the sweep starts, in seconds.
repeatbooleanfalseWhen text is an array, advance to the next string after each cycle.
repeatDelaynumber0.5Pause in seconds before replaying or advancing (when repeat is true).
startOnViewbooleantrueStart the animation when the element enters the viewport.
oncebooleantruePlay only the first time (when startOnView is used).
classNamestring—Additional CSS classes on the root span.
fixedWidthbooleanfalseLock width to the widest string when text is an array to reduce layout shift.

Credits

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

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

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

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

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

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.

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)
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.

// 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.

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