Skip to content
Haze UI

AI send with undo

In-chat editable email draft with 5-second countdown progress bar, Undo cancellation, and collapsible sent confirmation row.

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

When to use

  • Letting users review and edit an AI-drafted email inside a conversation before it goes out
  • Providing a visible grace period with an Undo button to prevent accidental outbound messages
  • Collapsing a completed email draft into a clean single-row delivery confirmation

When not to use

  • Offering an undo action for a generic page-level mutation outside chat; use undo-toast
  • Composing rich multi-attachment threads or inbox replies; build a dedicated mail composer

Installation

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

pnpm dlx shadcn@latest add @haze/ai-send
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
idstring"haze-ai-send"Unique prefix for field label associations and heading IDs.
headingstring"Email draft with undo"Screen-reader section heading for landmark navigation.
userPromptstring"Let Devon know the launch review moved to Thursday at 2"User message requesting the email draft.
assistantReplystring"Here's a draft. Change anything you like before it goes."Assistant reply introducing the editable email card.
recipientstring"Devon Park <[email protected]>"Initial value for the editable To input.
subjectstring"Launch review moved to Thursday"Initial value for the editable Subject input.
bodystring"Hi Devon, ..."Initial message content for the editable textarea.
senderstring"[email protected]"Sender email address displayed in the draft footer.
undoSecondsnumber5Duration in seconds for the undo countdown window.
classstring–Extra classes on the outer section.

Keyboard interactions

Tab
Move through To, Subject, Message fields, Send, Undo during countdown, and Draft again after delivery
EnterSpace
Start the send countdown, cancel delivery with Undo, or reopen the draft

Accessibility

  • The To, Subject, and Message inputs carry explicit label elements, and pressing Send moves keyboard focus directly to the Undo button during the countdown.
  • Countdown progress exposes role="progressbar" with live aria-valuenow updates and switches to discrete one-second steps when prefers-reduced-motion is active.

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 block "AI send with undo" with `npx shadcn@latest add @haze/ai-send`. 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 AiSend from "@/components/haze/blocks/ai-send.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/blocks/ai-send.md

  • Customize with real content

    Adapt the Haze ai-send block for our product. Replace the demo values of these props with our real content: id, heading, userPrompt, assistantReply, recipient, subject, body, sender, undoSeconds, class. Keep the layout, the heading level rules and these accessibility details: The To, Subject, and Message inputs carry explicit label elements, and pressing Send moves keyboard focus directly to the Undo button during the countdown. Countdown progress exposes role="progressbar" with live aria-valuenow updates and switches to discrete one-second steps when prefers-reduced-motion is active. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-send, check it fits: use it when letting users review and edit an ai-drafted email inside a conversation before it goes out; providing a visible grace period with an undo button to prevent accidental outbound messages; collapsing a completed email draft into a clean single-row delivery confirmation. Avoid it when offering an undo action for a generic page-level mutation outside chat; use undo-toast; composing rich multi-attachment threads or inbox replies; build a dedicated mail composer. Alternatives: @haze/undo-toast, @haze/ai-checkout, @haze/ai-schedule.

Dependencies

  • npm: @lucide/astro
  • @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