{"success":true,"name":"use-modals-rarely-and-build-them-right-when-you-do","description":"About to open a modal/popup for a new piece of frontend content.","category":"ai-brimind","path":"ai-brimind/use-modals-rarely-and-build-them-right-when-you-do/SKILL.md","file":"SKILL.md","content":"---\nname: use-modals-rarely-and-build-them-right-when-you-do\ndescription: \"About to open a modal/popup for a new piece of frontend content.\"\n---\n\n# Use Modals Rarely — and Build Them Right When You Do\n\n## When to use\nYou are deciding to put content or a flow inside a modal, and haven't questioned whether a modal is the right container.\n\n## Example request\nA 12-field form crammed in a modal → cramped scrolling misery; a dedicated page or side drawer is the right container. A modal opening another modal → users are trapped in layers; flows belong in pages or steppers. Modal closing on accidental backdrop click, losing typed data → rage; confirm-before-discard (or not closing on backdrop when there's input) is the pattern. No Escape key, no focus trap → keyboard users stuck; those behaviors are what makes a modal a modal.\n\n## Instructions\nAct like a gatekeeper who charges a heavy toll for every modal, because a modal interrupts everything the user was doing. Before creating one, classify the content: quick confirmation or tiny focused input (1-3 fields) → modal is fine; anything longer, multi-step, or worth a URL → use a page or side drawer instead, and say why. Never stack a modal on a modal — that's the signal the flow outgrew its container. When a modal IS justified, it must behave completely: focus moves into it on open and is trapped inside while open; Escape closes it; focus returns to the trigger on close; backdrop click closes it ONLY if no unsaved input exists — otherwise ask before discarding the user's work; the page behind doesn't scroll. These behaviors are exactly why you should reuse the project's or UI library's existing modal/dialog component (or the native dialog element) instead of hand-rolling a div overlay — the edge cases are already solved there. Title the modal with its purpose, make the primary action explicit ('Delete project', not 'OK'). If unsure whether content will grow later, prefer the drawer/page — modals age badly. Finish by justifying the container choice and walking the keyboard path (open, tab, escape) — proving the interruption is both earned and safe.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #407\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}