Build an Accessible Modal, Toast and Tooltip Showcase in One HTML File

You get a single HTML page with a modal dialog, toast notifications and tooltips. All three use focus trapping, Escape handling, correct ARIA roles and live-region announcements.

The prompt

Prompt
Act as a senior front-end engineer who specializes in accessible design systems.

Build a component showcase page called Harbor UI, an overlay kit for a fictional project-management app. It shows three production-ready patterns, each on its own card, plus a visual event log:

- **Modal dialog:** confirms archiving a project called Q3 Launch Plan.
- **Toast notifications:** cover success, error and a queue of three info updates.
- **Tooltips:** sit on icon buttons and an info icon.

Rules:
1. **Modal.** Use role dialog, aria-modal, aria-labelledby and aria-describedby. When it opens, focus moves to the least destructive button. Tab and Shift+Tab are trapped inside. Escape, Cancel, the close button or a backdrop click closes it. The page behind becomes inert, and focus returns to the trigger when it closes.
2. **Toasts.** Status toasts announce through a visually hidden polite live region. Errors use an assertive alert region. Toasts auto-dismiss after 5 seconds (8 for errors) with a progress bar. Hover or focus pauses the timer. Each toast has a labelled dismiss button, Escape dismisses a focused toast, and no more than four are shown at once.
3. **Tooltips.** Link each one with aria-describedby and role tooltip. Show on hover after a short delay and immediately on keyboard focus. Stay open while the tooltip itself is hovered. Escape hides it without moving focus. Clamp it inside the viewport.
4. **Layout.** Use a responsive card grid from 360 to 1280px, a clear type scale, warm paper background, ink text, one teal accent, red reserved for destructive actions, and a strong visible focus ring.
5. **Motion and markup.** Honor prefers-reduced-motion. Include a skip link. Use no forms, no external assets and no storage.

Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Harbor UI, an accessible overlay kit showcase.

  • Archive project… opens a modal. Tab cycles only inside it, and Esc closes it and returns focus to the trigger.
  • Toast buttons fire success, error and a queue of three updates. Hover a toast to pause its timer.
  • Icon buttons show tooltips on hover or focus. Press Esc to hide one.
  • Event log shows what screen readers hear.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • It names the exact ARIA roles and attributes, so the model follows WAI-ARIA patterns instead of improvising div-based overlays.
  • It specifies focus behavior for open, trap, Escape and return, which is where most homemade modals fail keyboard users.
  • Separate polite and assertive hidden live regions make announcements reliable while the visible toasts stay interactive.

Paste into ChatGPT, Claude or Gemini. Save the code as harbor-ui.html and open it in a browser, or use the chat's preview or canvas. Then unplug your mouse and try everything with the keyboard.

Common edits

  • Swap the teal accent and the copy for your brand to drop the components into a real design system demo.
  • Add a drawer or popover menu card that reuses the same focus-trap and Escape logic.

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

Keep exploring

More in Design