MeDo

AIモーダルジェネレーター。

必要なダイアログを説明すれば、MeDoがすべてを生成します — ヘッダー、スクロール可能なボディ、アクションフッター、さらにフォーカストラップ、閉じる際のフォーカス復元、body のスクロールロック、モバイル向けボトムシートバリアントまで。

モーダル
モーダル

モーダルの難所は、その背後にあるページ

モーダルはシャドウ付きの中央寄せの箱に見えます。だからこそ、何度も雑に作り直されるのです。見た目のレイヤーは些細で、難しい部分はコンポーネントの外側にすべて存在します。ダイアログを開くときは、下にあるドキュメントを固定し、Tab が隠れたコンテンツへ迷い込まないようキーボードフォーカスを捕らえ、ページの残りを支援技術から隠し、そして閉じたときには開いた要素そのものへフォーカスを戻さなければなりません。最後の一手を忘れると、キーボードユーザーは何の知らせもなくドキュメントの先頭に戻され、自分の位置がわからなくなります。ダイアログとそのフォーカス契約を一緒に生成すれば、このステートマシンはQAの後で継ぎ足すのではなく、最初のレンダリングから正しく動きます。

6 個のテンプレート

生成できる モーダル テンプレート

どのテンプレートもスクリーンショットではなく実際のプロンプトです。任意の AI エディタに貼り付けるか、MeDo で実行して React + Tailwind のコードを受け取れます。

BasicHeader + Footer

Composable Dialog With Focus Management

The base every other dialog extends. The visual layer takes minutes; the focus contract is the part worth generating rather than hand-writing.

Create a modal dialog with three sizes — sm 400px, md 560px, lg 760px — centered over a black backdrop at 50 percent opacity, 16px radius, soft shadow. Compose it from Header, Body and Footer slots: the header holds a title and an icon-only close button with an aria-label, the body scrolls independently at max-height 70vh, and the footer right-aligns Cancel next to a primary action. On open, move focus to the first interactive element, trap Tab and Shift+Tab inside the dialog, and lock body scroll by compensating for the scrollbar width so the page does not shift. Set role="dialog", aria-modal="true" and aria-labelledby pointing at the title, and restore focus to the trigger on close.

MeDoで試す
ConfirmationDestructive Confirm

Non-Dismissible Delete Dialog

The one dialog that must ignore Escape and backdrop clicks. A stray click outside the box should never be the gesture that deletes an account.

Create a destructive confirmation dialog: a warning icon, a heading naming the exact resource, a body stating what will be lost and whether it is recoverable, and a footer with Cancel on the left and a red Confirm on the right. Ignore both Escape and backdrop clicks so the action requires a deliberate button press. Move initial focus to Cancel rather than Confirm, so a stray Enter keypress cancels instead of destroying. Use role="alertdialog" with aria-describedby on the body text. Add an optional type-to-confirm mode requiring the resource name to be typed before Confirm enables, with the comparison case-sensitive and trimmed.

MeDoで試す
FormForm Dialog

Scrolling Form With Sticky Actions

A long form in a dialog needs a body that scrolls under a fixed header and footer, plus an unsaved-changes guard. Losing typed input to a misclick is unforgivable.

Create a form dialog with a fixed header, a scrolling body and a sticky footer holding Cancel and Save. Keep the header and footer outside the scroll container so the actions stay reachable in a long form. Add a dirty-state guard: when any field has changed, intercept Escape and backdrop clicks and show a nested confirm-discard step inside the same dialog rather than opening a second overlay. On validation failure, move focus to the first invalid field and scroll it into view inside the body. Set aria-busy while saving, disable Save without removing it from the tab order, and close only after the request resolves.

MeDoで試す
MobileBottom Sheet

Sheet That Slides Up on Phones

A centered card on a phone leaves the buttons floating mid-screen, away from the thumb. Same component, different layout under 640px.

Create a dialog that renders as a centered card above 640px and as a bottom sheet below it: full width, rounded top corners only, sliding up from the bottom edge with a 250ms ease-out transform. Add a drag handle at the top and support swipe-to-dismiss with a velocity threshold, falling back to the close button for keyboard and assistive technology. Cap the sheet height at 90vh with the body scrolling inside, and use dynamic viewport units so the mobile browser chrome does not clip the footer. Keep focus trapping and scroll lock identical in both layouts, and disable the slide animation under prefers-reduced-motion.

MeDoで試す
PlatformNative Dialog

HTML dialog With showModal

The browser already ships focus trapping, top-layer stacking and Escape handling. Choose this and you delete most of the code the custom overlay needed.

Create a modal built on the native HTML dialog element opened with showModal(), so the browser supplies focus trapping, Escape handling and top-layer stacking with no z-index management. Style the backdrop through the ::backdrop pseudo-element. Add the parts the platform does not give you: body scroll lock on open, an entry and exit animation using allow-discrete and the transition-behavior property, and a close-on-backdrop handler that compares the click target to the dialog element rather than its children. Listen for the close event to restore focus and read returnValue, and use autofocus on the element that should receive focus first.

MeDoで試す
OverlayCommand Palette

Cmd+K Search Dialog

A modal whose focus stays in the input while arrow keys drive a list elsewhere. Roving focus would break typing, so this one runs on aria-activedescendant.

Create a command palette dialog opened by Cmd+K or Ctrl+K: a search input at the top with results grouped by section below, positioned near the top of the viewport rather than vertically centered. Keep DOM focus in the input at all times and move the visual selection with aria-activedescendant so arrow keys navigate the list without stealing focus from typing. Support Enter to run the highlighted command, Escape to close with focus restored to the previously active element, and a scroll-into-view on the highlighted row. Debounce the query, render an empty state naming what was searched for, and announce the result count through a polite live region.

MeDoで試す

モーダル をカスタマイズする方法

閉じられてはいけないダイアログを明示する

Escape とバックドロップクリックは情報提供ダイアログには適切な既定動作ですが、破壊的な確認や未保存の入力を含む複数ステップのフォームでは危険です。両方を無視すべきバリアントを指定して、箱の外の不意なクリックでアカウントが削除されないようにしましょう。

フォーカストラップだけでなくフォーカス復元も依頼する

ほとんどのプロンプトはトラップだけ実現して帰り道を忘れます。閉じるときにフォーカスがトリガー要素へ戻ること、そして開くときにダイアログがその参照を保持することを指定すれば、キーボードユーザーは中断した場所から正確に再開できます。

ブレークポイントごとに中央配置かボトムシートを選ぶ

スマートフォンで中央配置のダイアログを使うと、アクションボタンが画面の中ほどに浮いて親指から遠くなります。640px 未満では主要アクションが届く位置に来るボトムシートを依頼し、より広いビューポートでは中央配置レイアウトを保ちましょう。

モーダルの中からモーダルを開かない

最初のダイアログの上に2つ目を重ねるとフォーカストラップが壊れ、バックドロップが二重になり、Escape がどのレイヤーを閉じるのか曖昧になります。代わりに1つのダイアログ内でステップ形式のコンテンツを依頼し、オーバーレイをフォーカスの持ち主が1つだけの単一レイヤーに保ちましょう。

モーダル コンポーネントを使うのは誰か

SaaSプロダクト

サブスクリプション解約用の閉じられない確認ダイアログ。ボディにプラン名を再掲し、確認ボタンは赤色。あわせて、チームメンバー招待用の軽量で閉じられるダイアログも用意します。

Eコマースストア

商品画像、サイズセレクター、カートに追加ボタンを収めたクイックビューダイアログ。スマートフォンではボトムシートとしてレンダリングし、サイズ選択とカートボタンの両方が親指の届く範囲に収まります。

ダッシュボードや管理ツール

正確なレコード件数を示し、確認ボタンが有効になる前にリソース名の入力を求める一括削除の確認ダイアログ。加えて、固定ヘッダーとフッターの内側で長いフォームがスクロールする編集ダイアログ。

コンテンツ・メディアサイト

フルサイズ画像用のライトボックスダイアログ。矢印キーでのナビゲーション、Escape で閉じる操作、そして開いたサムネイルへのフォーカス復元により、ギャラリー内の閲覧位置が失われません。

サイト種別ごとの モーダル パターン

同じ モーダル コンポーネントを、掲載するサイトの種類に合わせて調整します。

01 / 06

SaaS Product Dialogs

Two classes of dialog with opposite dismissal rules: invite-a-teammate should close on Escape and backdrop click, cancel-my-subscription should close on neither. Decide that per variant rather than globally, because a single dismissal policy across a product means either annoying dialogs or destroyed data.

モーダル のスタイルとバリアント

ページ全体のトーンに合うバリアントを選び、そのまま生成します。

01 / 06

Centered Dialog

The default above 640px: a fixed-width card centered over a dimmed backdrop. Cap the height at around 70vh with the body scrolling internally, because a dialog taller than the viewport pushes its own footer out of reach and there is no page scroll left to recover it.

React・Next.js・Vue・Svelte での モーダル

React、Next.js、Vue 3、SvelteKit、Astro、素の HTML — 同じ モーダル を 6 通りの方法で組み込めます。

01 / 06

React Modal

Render through a portal so the dialog escapes any ancestor with overflow hidden or a transform, both of which would clip it. Store the trigger element on open and focus it again in the cleanup, which is the step most hand-rolled modals skip.

src/components/Modal.tsx

export function Modal({ open, onClose, children }) {
  const trigger = useRef(null)

  useEffect(() => {
    if (!open) return
    trigger.current = document.activeElement
    return () => trigger.current?.focus()
  }, [open])

  if (!open) return null
  return createPortal(
    <div role="dialog" aria-modal="true">{children}</div>,
    document.body
  )
}

モーダル をプロジェクトに追加する方法

モーダル テンプレートを選んで本番に載せるまでの 4 ステップ。

01~30s

Pick a Dialog Template

Scan the six templates and start from the interaction — a destructive confirm, a scrolling form, a mobile bottom sheet, or a Cmd+K palette.

02~10s

Copy the Prompt

Take the prompt into MeDo, Lovable, Bolt, v0 or Cursor. State whether this dialog may be dismissed by Escape and backdrop click before you run it, since that single decision separates a helpful overlay from one that deletes data on a misclick.

03~1min

Generate and Refine

You get React + Tailwind back with a live preview. Follow up in plain English — "make it a bottom sheet under 640px", "focus Cancel first", "build it on the native dialog element" — rather than rewiring the focus trap yourself.

04~2min

Test It With the Keyboard Only

Open it, Tab to the end and confirm focus cycles instead of escaping into the page, then close it and check focus returned to the trigger. Those two checks catch nearly every modal defect that ships.

モーダルに関するよくある質問

AIでモーダルコンポーネントを生成するには?

レイアウト、サイズ、閉じ方のルールを1つのプロンプトで説明します。たとえば「スクロール可能なボディ、キャンセルと確認のアクション、Escape を無視する破壊的バリアントを備えた 560px の中央配置ダイアログ」のように。MeDo はフォーカストラップ、フォーカス復元、スクロールロック、ダイアログセマンティクスを含めてコンポーネントを生成するため、スタイルを当てた div ではなく実際に動くオーバーレイが得られます。

フォーカストラップとは何で、なぜモーダルに必要なのですか?

フォーカストラップは Tab と Shift+Tab をダイアログ内のインタラクティブ要素の中で循環させ、下のページへ逃げないようにします。これがないと、キーボードユーザーは確認ボタンを越えて見えないリンクへ移動してしまい、混乱を招くうえ WCAG 違反にもなります。トラップは常にフォーカス復元と組み合わせ、ダイアログを閉じたときにトリガー要素へフォーカスを戻すべきです。

バックドロップをクリックしたらモーダルは閉じるべきですか?

情報提供やリスクの低いダイアログなら、はい — バックドロップクリックと Escape は多くの人が期待する閉じ方です。破壊的な確認や未保存の入力があるフォームでは、いいえ。箱の外を誤ってクリックしただけでデータが消えたり入力が破棄されてはいけません。取り消せない操作には明示的なボタン押下を必須にしましょう。

カスタムモーダルの代わりにネイティブの HTML <dialog> 要素を使えますか?

多くの場合使えます。showModal() を伴うネイティブの <dialog> 要素は、フォーカストラップ、Escape の処理、トップレイヤーでの重ね合わせ、::backdrop 疑似要素を無償で提供し、z-index の管理も不要です。ただし body のスクロールロックとアニメーションは自分で実装する必要があり、古いブラウザーにはフォールバックが必要です。ネイティブ要素を使いたいと MeDo に伝えれば、挙動を再実装せずその上に構築します。

モバイルでモーダルはどう振る舞うべきですか?

おおよそ 640px 未満では、中央配置のカードよりボトムシートのほうが優れているのが普通です。主要アクションを親指の近くに固定し、フォームフィールドに画面幅をすべて使え、ユーザーが既に知っているプラットフォームの慣習に沿います。MeDo は両方のレイアウトを1つのコンポーネントで生成し、指定したブレークポイントで切り替えられます。

モーダルに role="dialog" と aria-modal は必要ですか?

はい。セマンティクスを自ら備えるネイティブの <dialog> 要素を使う場合を除いて必要です。カスタムのオーバーレイには role="dialog"、aria-modal="true"、そして表示されているタイトルを指す aria-labelledby か、見出しがない場合の aria-label が必要です。aria-modal がないと、スクリーンリーダーはオーバーレイ背後のページを引き続き閲覧可能なコンテンツとして読み上げます。