Skip to content
Haze UI

Text reveal

Short text reveals its words on request while a complete readable sentence remains present from the start.

pnpm dlx shadcn@latest add @haze/text-reveal
Open preview in a new tab
Livesmall script

When to use

  • A user action should replay a brief word reveal without delaying access to the text
  • A short statement needs a restrained response to an explicit reveal event

When not to use

  • Use in-view-title when entering the reading viewport should trigger the response
  • Use text-morph when the content itself changes between labels

Installation

Add the Haze registry to components.json once, then install Text reveal with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/text-reveal
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller-supplied prefix for this component and its related elements.
textstring"Good work starts with a clear next step."Complete readable sentence to reveal.
headingLevel"h2" | "h3" | "h4"–Optional heading element; omitted renders a paragraph.
replaybooleanfalseShows an enhanced replay button.
replayLabelstring"Reveal again"Visible replay button text.
classstring–Additional classes for the component root.

Keyboard interactions

Tab, Enter or Space
Reach the optional replay button and reveal the text again.

Accessibility

  • Assistive technology reads one complete sentence; individual animated words are hidden from its reading order.
  • The initial text is never hidden or staggered on page load; the host dispatches haze:reveal or enables the replay button.
  • The whole response is capped at 300 ms and reduced motion leaves the text still.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Text reveal" with `npx shadcn@latest add @haze/text-reveal`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import TextReveal from "@/components/haze/ui/text-reveal.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/text-reveal.md

  • Customize with real content

    Adapt the Haze text-reveal ui for our product. Replace the demo values of these props with our real content: id, text, headingLevel, replay, replayLabel, class. Keep the layout, the heading level rules and these accessibility details: Assistive technology reads one complete sentence; individual animated words are hidden from its reading order. The initial text is never hidden or staggered on page load; the host dispatches haze:reveal or enables the replay button. The whole response is capped at 300 ms and reduced motion leaves the text still. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using text-reveal, check it fits: use it when a user action should replay a brief word reveal without delaying access to the text; a short statement needs a restrained response to an explicit reveal event. Avoid it when use in-view-title when entering the reading viewport should trigger the response; use text-morph when the content itself changes between labels. Alternatives: @haze/in-view-title, @haze/text-morph, @haze/section-heading.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog