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
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
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
Did this prompt work?
Keep exploring
More like this
Build a Light/Dark Mode Toggle Demo Page with Smooth Theme Switching
A single HTML page with a polished light/dark theme switch built on CSS custom properties that defaults to the system theme, honors reduced motion, and uses no storage.
Build a Multi-Step Onboarding Wizard with Stepper and Inline Validation
A four-step onboarding wizard in one HTML file, with a clickable stepper, progress bar, inline validation, a review screen, and keyboard and swipe navigation.
Build a Playful Animated 404 Error Page with SVG Art and Site Search
A complete single-file 404 page with an original animated hot-air balloon SVG, a live-filtering search box and helpful recovery links that respect reduced motion.
Build a Responsive Navigation Bar With Mega Menu and Mobile Drawer in HTML
A complete single-file site header with a hover, click and arrow-key mega menu on desktop and an animated hamburger drawer with accordions on small screens.
Build a Responsive Three-Tier Pricing Section with Monthly/Yearly Toggle
A single HTML file with three pricing cards, a working billing switch that recalculates prices, a highlighted recommended plan and accessible feature checkmarks.
Design an Accessible Settings Page with Toggles, Segmented Controls and Sliders
A ready-to-paste prompt that builds a polished single-file settings page with custom accessible toggles, segmented controls and sliders that update a live reading preview.
- Build a Button and Form Field States Reference Sheet in a Single HTML File
- Build a Color Blindness Simulator That Previews a Palette on a Dashboard Card
- Build a Drag-to-Arrange Brand Mood Board with Color, Texture and Type Tiles
- Build a Draggable Color Harmony Wheel With Live UI Preview in One HTML File
- Build a Live Accessible Color Palette Builder with a WCAG Contrast Matrix
- Build a SaaS Landing Page Hero with a CSS-Drawn Product Mockup