Modal And Overlay Patterns 标志

Modal And Overlay Patterns

组织
dembrandt
modal-and-overlay-patterns

Modals, drawers, bottom sheets and popovers, each with its scope and blocking level. Use when designing dialogs, confirmations, side panels or action sheets.

Add to TypingMind

概览

发布者dembrandt
代码仓库dembrandt-skills
技能名称modal-and-overlay-patterns
星标数
169
复刻数
21
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 dembrandt 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Modal And Overlay Patterns AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/dembrandt/dembrandt-skills/tree/main/skills/modal-and-overlay-patterns
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dembrandt/dembrandt-skills.git /tmp/dembrandt-skills
mkdir -p .claude/skills
cp -r /tmp/dembrandt-skills/skills/modal-and-overlay-patterns .claude/skills/modal-and-overlay-patterns
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Modal And Overlay Patterns,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Modal And Overlay Patterns。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Modal And Overlay Patterns 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Modal and Overlay Patterns

Overlays appear above the main content layer. They range from lightweight popovers (non-blocking, anchored to a trigger) to full blocking modals (require a user response before the app continues). Choosing the right overlay type for the task prevents unnecessary interruption and keeps the user oriented.


The Overlay Hierarchy

Choose the lightest type that satisfies the task. Heavier overlays carry higher cognitive cost.

TypeBlocks backgroundAnchored to triggerTypical contentDismiss with
TooltipNoYes1–2 lines of explanatory textCursor leave / focus out
PopoverNoYesShort interactive content: a form field, a picker, a small listClick outside, Escape, explicit close
Dropdown / MenuNoYesList of actions or optionsClick outside, Escape, selection
Bottom sheet (mobile)Partial (dimmed)NoActions or content on small screensSwipe down, tap scrim, Escape
Drawer / Side panelPartial (dimmed)NoSecondary editing, detail views, long formsEscape, explicit close; optionally click scrim
Dialog / ModalYes (full scrim)NoBlocking task: confirm action, fill required formEscape (non-destructive only), explicit button
Full-screen overlayYes (complete)NoImmersive task: media viewer, complex configurationExplicit close only

Decision rule: If the user can continue using the rest of the app while the overlay is open, use a non-blocking type (drawer, popover). If the app must wait for the user's response, use a modal.


One Shell for the Whole Family

Tooltip, popover, drawer, bottom sheet and dialog are one family, not five components. They share a single shell: the same raised surface, one hairline border, one corner radius, and a shadow that grows with modality. The ones that carry a header and footer share what sits inside: a title that names the object, a hairline under the header, and one footer order used everywhere. Only size, anchoring (arrow or centred) and blocking change between them.

When each overlay is styled on its own, the user meets several dialects of the same message: different radii, button orders and confirm labels. Each one costs a moment of re-learning and makes a destructive confirm easier to misread. One shell is also one code primitive and one design-tool family, so a fix lands everywhere.

Audit before adding. List every floating surface in the product and the tokens it uses. Extract the shell into one primitive and build each overlay type on it. The usual find is a confirm popover and a dialog that disagree on footer order, or a dialog header still carrying a heavy rule the rest of the UI has dropped.


Tooltip

A tooltip appears on hover or keyboard focus and disappears when the trigger loses focus. It is purely informational — no interactive elements inside.

  • Content: one short sentence, label, or keyboard shortcut. Never put a link or button inside a tooltip.
  • Delay: 300–400ms on hover; no delay on keyboard focus.
  • Position: prefer above the trigger; auto-flip when viewport edge is near.
  • ARIA: role="tooltip" on the element; aria-describedby on the trigger pointing to the tooltip id.

Popover

A popover is anchored to a trigger but contains interactive content — a colour picker, a date range selector, a small form, a list of filters. Unlike a tooltip, it stays open while the user interacts.

  • Max width: 280–360px. For larger content, use a drawer.
  • Position: anchored to the trigger; auto-flip to stay in viewport.
  • Dismiss: click outside, Escape key, or explicit close button when the content is long.
  • Focus: move focus into the popover when it opens; return focus to the trigger on close.
  • ARIA: role="dialog" (if interactive) or role="listbox" (if a list); aria-haspopup on the trigger.

Dropdown and Menu

A dropdown lists selectable options or actions anchored to a trigger button. It is the lightest interactive overlay.

  • Separate select dropdowns (the user picks one value that persists) from action menus (the user triggers an action that doesn't persist as a value).
  • Width: at least as wide as the trigger; cap at 280px.
  • Long lists: add a search input at the top when there are more than 8–10 items.
  • Keyboard: ↑/↓ to move between items, Enter to select, Escape to close.

Bottom Sheet (Mobile)

On small screens, a bottom sheet replaces modals and popovers. It slides up from the bottom edge and feels native to touch devices.

  • Peek height: Show a small portion of the sheet first (a handle + title), let the user drag to expand.
  • Full-height: For longer content or forms that need the full viewport.
  • Dismiss: swipe down, tap the scrim, or press Escape.
  • Do not centre dialogs on mobile — use a bottom sheet instead (centred modals are too small and hard to reach).
  • ARIA: treat as role="dialog" with the same focus management as a modal.

Drawer / Side Panel

A drawer slides in from the left or right and partially covers the main content. Use it for secondary editing tasks, detail views, or settings that the user might refer back to while using the main content.

  • Right drawer: Detail view, editing form, filter/sort panel. Most common.
  • Left drawer: Navigation on mobile (hamburger menu pattern).
  • Width: 320–480px on desktop. Full-width on mobile (effectively a bottom sheet or full-screen overlay instead).
  • Scrim: a semi-transparent backdrop (rgba(0,0,0,0.4)) behind the drawer dims the main content.
  • Dismiss: Escape key, explicit close button. Clicking the scrim is optional — avoid it when the drawer contains an unsaved form.
  • Do not use a drawer when the task is blocking (e.g. a required decision). Use a modal instead.
  • ARIA: role="dialog", aria-modal="true", aria-labelledby pointing to the drawer title.

Modal / Dialog

A modal blocks the entire UI with a full scrim. Use it only when the app genuinely cannot continue without the user's response.

When to use a modal

  • Confirming a destructive or irreversible action
  • A required form that must be submitted before continuing
  • An error or warning that requires the user's acknowledgement

When not to use a modal

  • Displaying information the user can read at their leisure → use an inline notice or notification
  • A task the user might want to do alongside the main content → use a drawer
  • A large form with many fields → use a dedicated page or a drawer

The tab-close case

beforeunload shows the browser's own generic dialog and nothing else. No script runs and no custom markup paints between that dialog and the unload. Do not design a "rate before you leave" or "review your changes" flow around it. Gate on actions the app controls (close button, route change, new search) and treat tab close as an escape hatch.

Anatomy

┌──────────────────────────────────┐
│  Title                      [✕]  │  ← Header: title + close button
├──────────────────────────────────┤
│                                  │
│  Body content                    │  ← Content: scrolls if needed
│  (description, form, media)      │
│                                  │
├──────────────────────────────────┤
│               [Cancel]  [Confirm]│  ← Footer: actions, right-aligned
└──────────────────────────────────┘

Sizing

SizeWidthUse for
Small360pxShort confirmations, single-field prompts
Medium480pxStandard dialogs, short forms
Large640pxMulti-field forms, richer content
Full-screen100% viewportImmersive tasks; use sparingly

Content that overflows the modal height should scroll within the body area only — the header and footer must remain visible.

A mobile-first dialog gets its own desktop layout. A phone-width card centred on a large screen reads cramped and unfinished: options wrap into one narrow column and targets sit closer than the space allows. Give the desktop breakpoint its own width, column count and spacing while mobile keeps the original.

Two or three sub-choices per option go inline. When every option in a picker offers only a couple of second-level choices, render them as always-visible links under the option. An accordion or a second dialog costs a click and hides what is available, and a separate selector for the second dimension lets the user pick combinations that do not exist.

Dismiss behaviour

TriggerAllowed for non-destructive?Allowed for destructive?
Escape keyYesNo — require explicit Cancel
Click outside scrimYes (optional)No — too easy to dismiss accidentally
Close button (✕)YesYes
Cancel buttonYesYes

For destructive or irreversible actions: disable Escape and click-outside dismissal. The user must explicitly press Cancel or Confirm.

Stacking modals

Avoid opening a modal from inside a modal. It signals an information architecture problem — the task is likely too complex for a single dialog.

If a secondary overlay is unavoidable, use a popover anchored inside the modal rather than another full modal. Never stack two blocking scrim overlays.


Lightbox / Media Viewer

A lightbox may omit a visible title and body text, but it still has interactive controls (close, paging and zoom) and must remain an accessible named dialog. The rules about scrim, dismissal, focus and text alternatives still apply; zoom and paging are the whole interaction, and they need as much design as any form.

Open at the item that was clicked. Every thumbnail opens the viewer at its own index, not at the first image. Escape closes; focus lands on the close button on open and returns to the thumbnail on close.

Two input models, chosen by pointer type, not by screen width. matchMedia('(pointer: fine)') at runtime picks the default, because a laptop with a touch screen and a tablet with a trackpad both exist. It only reports the primary pointer, so keep both models live and let each event's pointerType decide.

  • Fine pointer: a click toggles zoom at the pointer position. Pan either by moving the pointer (fast, but the image shifts whenever the user reaches for the close button) or by dragging (calmer, one more gesture to learn). Pick one and keep it across the product.
  • Coarse pointer: pinch zooms, double tap toggles, drag pans. These are what the platform taught the user.

Gestures alone are not enough. Visible + / − buttons give the zoom a discoverable and keyboard reachable path. Disable − at 1× and + at the maximum, so the buttons also tell the user where they are. Binding the + / − keys and arrow keys for panning is a sound extension of the same rule.

Two-tier zoom. A click or double tap goes to a fixed detail level at the point the user touched. The buttons step further, to a hard maximum. The levels depend on the material: for example 2× and 4× for product photography, further for maps, scans or dense diagrams. A single jump to maximum lands the user on a blur of pixels with no idea where they are.

The cursor announces the next action. Show a zoom-in cursor at 1×, a zoom-out cursor when zoomed, and an expand cursor on the thumbnails that open the viewer. If the zoom implementation sets its own cursor: move on the zoomed image, override it, or the hint changes mid-interaction.

Separate a drag from a click. A press that moves more than a few pixels (~5 px) before release is a pan and must not toggle zoom on release, or every pan ends by snapping the image back to 1×.

Zoom belongs to one image. Reset to 1× when the user moves to the next image, and let the swipe reach the carousel again once the image is back at 1×.

Fixed positions for the overlay tools. Close top-right, pager bottom-centre, zoom controls bottom-right. Users learn these once; moving them per screen costs that learning.

Announce the state. Every icon button carries an aria-label. Beyond that, the accessible baseline is the same as any dialog: expose the current scale to screen readers, in the button label ("Zoom in, currently 2×") or with a polite live region, and respect prefers-reduced-motion for the zoom transition. See [[wcag-accessibility]].


Focus Management

Every overlay must manage focus correctly. Broken focus management is one of the most common accessibility failures.

On open

  1. Move focus to the first interactive element inside the overlay (usually the first field, or the confirm button for confirmations).
  2. Trap focus: Tab and Shift+Tab cycle within the overlay only; focus cannot escape to the content behind the scrim.

On close

Return focus to the element that triggered the overlay. If the trigger no longer exists (the element was deleted), move focus to a logical nearby element.

Implementation note

Use a focus trap library or the native <dialog> element, which handles trapping natively in modern browsers. Rolling a manual focus trap is error-prone.


ARIA for Modals and Drawers

html
<div
  role="dialog"
  aria-modal="true"
  aria-labelledby="modal-title"
  aria-describedby="modal-description"
>
  <h2 id="modal-title">Delete project?</h2>
  <p id="modal-description">
    This will permanently delete "Apollo" and all its data. This cannot be undone.
  </p>
  <button>Cancel</button>
  <button>Delete</button>
</div>
  • role="dialog" on the container
  • aria-modal="true" tells screen readers to ignore content behind the overlay
  • aria-labelledby points to the dialog title's id
  • aria-describedby points to the description's id (optional but helpful for confirmations)
  • The scrim backdrop should have aria-hidden="true" — screen readers must not read it

Destructive Confirmation Pattern

Confirmation dialogs for destructive actions must name the item and consequence. Generic "Are you sure?" dialogs don't give enough context.

Do:

Delete "Apollo Project"? This will permanently remove all tasks, files, and history. This cannot be undone. [Cancel] [Delete project]

Don't:

Are you sure you want to do this? [No] [Yes]

  • The primary destructive action button uses --color-error / --color-danger, not --color-primary.
  • Label the destructive button explicitly: "Delete project", "Remove member", "Cancel order" — not just "OK" or "Confirm".
  • Cancel is always on the left (or secondary position); destructive action on the right.

Tooltips on Packed Cells

A tooltip on one cell of a flush group opens clear of the whole group. When cells sit flush in a grid, treemap or segmented mark, position each cell's tooltip above or beside the entire group, never over a sibling: a tooltip anchored to a bottom-row cell hides the row the reader is about to point at. Make the tooltip ignore the pointer so moving to the neighbour opens the next one.


Review Checklist

  • Is the correct overlay type chosen for the task (tooltip / popover / menu / bottom sheet / drawer / modal)?
  • Is a modal avoided when a drawer or inline pattern would suffice?
  • Does the modal/drawer have a visible title, body, and clear action buttons?
  • Does overflow content scroll within the body — with the header and footer fixed?
  • Is Escape disabled for destructive actions (click-outside too)?
  • Does focus move into the overlay on open, and return to the trigger on close?
  • Is focus trapped within the overlay while it's open?
  • Is role="dialog", aria-modal="true", aria-labelledby set correctly?
  • Does the destructive confirm dialog name the item and describe the consequence?
  • Is the destructive button labelled explicitly (not "OK" or "Confirm")?
  • Are stacked modals avoided?
  • Is no custom UI designed around beforeunload?
  • On mobile, are modals replaced with bottom sheets?
  • Lightbox: does the click/pan model follow pointer type, with +/− buttons and keys beside the gestures?
  • Lightbox: does the cursor say zoom-in / zoom-out, and does a pan never toggle zoom on release?
  • Lightbox: does zoom reset on page change, and is the current scale exposed to screen readers?
  • Do tooltips on flush cells open outside the group and let the pointer pass to the neighbour?
  • Do all overlays share one shell (surface, border, radius, shadow scale) and one footer order?

常见问题

Modal And Overlay Patterns AI 技能有什么作用?

Modals, drawers, bottom sheets and popovers, each with its scope and blocking level. Use when designing dialogs, confirmations, side panels or action sheets.

为什么在 TypingMind 中使用 Modal And Overlay Patterns?

因为您只需安装一次,就能搭配任何模型使用。Modal And Overlay Patterns 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Modal And Overlay Patterns?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/dembrandt/dembrandt-skills/tree/main/skills/modal-and-overlay-patterns。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Modal And Overlay Patterns?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Modal And Overlay Patterns 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Modal And Overlay Patterns 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Modal And Overlay Patterns AI 技能免费吗?

是的。dembrandt 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇