MeDo

KI-Modal-Generator.

Beschreiben Sie den Dialog, den Sie brauchen, und MeDo generiert das Ganze — Header, scrollbaren Body und Action-Footer, plus Fokus-Trap, Fokus-Rückgabe beim Schließen, Scroll-Sperre des Bodys und eine mobile Bottom-Sheet-Variante.

Modal
Modal

Das Schwierige an einem Modal ist die Seite dahinter

Ein Modal sieht aus wie eine zentrierte Box mit Schatten — genau deshalb wird es so oft schlecht neu gebaut. Die visuelle Ebene ist trivial; der schwierige Teil liegt vollständig außerhalb der Komponente. Das Öffnen eines Dialogs muss das Dokument darunter einfrieren, den Tastaturfokus einfangen, damit Tab nicht in verborgene Inhalte abwandert, den Rest der Seite vor assistiven Technologien verbergen und den Fokus danach genau auf das Element zurücksetzen, das ihn geöffnet hat. Wird der letzte Schritt vergessen, landet ein Tastaturnutzer stillschweigend am Anfang des Dokuments und weiß nicht, wo er ist. Den Dialog und seinen Fokus-Vertrag zusammen zu generieren bedeutet, dass diese Zustandsmaschine schon beim ersten Rendern korrekt ist und nicht erst nach dem QA-Durchlauf nachgeflickt wird.

6 Vorlagen

Modal-Vorlagen, die Sie generieren können

Jede Vorlage ist ein echter Prompt, kein Screenshot. Kopieren Sie ihn in einen KI-Editor oder führen Sie ihn in MeDo aus und erhalten Sie React- und Tailwind-Code zurück.

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.

In MeDo testen
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.

In MeDo testen
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.

In MeDo testen
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.

In MeDo testen
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.

In MeDo testen
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.

In MeDo testen

So passen Sie Ihre Modal an

Sagen Sie, welche Dialoge nicht schließbar sein dürfen

Escape und Backdrop-Klicks sind der richtige Standard für informative Dialoge, aber ein Risiko bei destruktiven Bestätigungen und mehrstufigen Formularen mit ungespeicherten Eingaben. Benennen Sie die Varianten, die beides ignorieren sollen, damit ein versehentlicher Klick außerhalb der Box kein Konto löscht.

Fordern Sie Fokus-Rückgabe, nicht nur Fokus-Trap

Die meisten Prompts bekommen den Trap hin und vergessen den Rückweg. Legen Sie fest, dass der Fokus beim Schließen zum auslösenden Element zurückkehrt und der Dialog diese Referenz beim Öffnen speichert, damit Tastaturnutzer genau dort weitermachen, wo sie waren.

Wählen Sie zentriert oder Bottom Sheet pro Breakpoint

Ein zentrierter Dialog auf dem Smartphone lässt die Aktionsschaltflächen mitten auf dem Bildschirm schweben, weit vom Daumen entfernt. Fordern Sie unter 640px ein Bottom Sheet mit der Primäraktion in Reichweite und behalten Sie das zentrierte Layout für breitere Viewports.

Öffnen Sie nie ein Modal aus einem Modal heraus

Ein zweiter Dialog über dem ersten bricht den Fokus-Trap, verdoppelt den Backdrop und macht unklar, welche Ebene Escape schließt. Fordern Sie stattdessen schrittbasierte Inhalte innerhalb eines Dialogs, damit das Overlay eine einzige Ebene mit einem Fokus-Besitzer bleibt.

Wer die Modal-Komponente nutzt

SaaS-Produkt

Ein nicht schließbarer Bestätigungsdialog zum Kündigen eines Abonnements, mit dem Tarifnamen im Body wiederholt und einer roten Bestätigen-Schaltfläche, daneben ein leichterer, schließbarer Dialog zum Einladen von Teammitgliedern.

Online-Shop

Ein Quick-View-Dialog mit Produktbildern, Größenauswahl und einer In-den-Warenkorb-Schaltfläche, auf Smartphones als Bottom Sheet gerendert, damit Größenoptionen und Warenkorb-Schaltfläche in Daumenreichweite bleiben.

Dashboard oder Admin-Tool

Eine Massenlöschen-Bestätigung, die die exakte Datensatzanzahl nennt und die Eingabe des Ressourcennamens verlangt, bevor Bestätigen aktiv wird, gepaart mit einem Bearbeitungsdialog, dessen langes Formular zwischen fixem Header und Footer scrollt.

Content- oder Medienseite

Ein Lightbox-Dialog für Bilder in Originalgröße mit Pfeiltasten-Navigation, Escape zum Schließen und Fokus-Rückgabe auf das Thumbnail, das ihn geöffnet hat, damit die Leseposition in der Galerie nie verloren geht.

Modal-Muster für verschiedene Websites

Dieselbe modal-Komponente, abgestimmt auf die Art der Website, auf der sie läuft.

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.

Modal-Stile und -Varianten

Wählen Sie die Variante, die zum Rest der Seite passt, und generieren Sie sie.

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.

Modal in React, Next.js, Vue und Svelte

React, Next.js, Vue 3, SvelteKit, Astro oder reines HTML — dieselbe modal, sechs Wege zur Einbindung.

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
  )
}

So fügen Sie Ihre Modal einem Projekt hinzu

Vier Schritte, von der Auswahl einer modal-Vorlage bis zum Einsatz in der Produktion.

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.

Häufige Fragen zu Modal

Wie generiere ich eine Modal-Komponente mit KI?

Beschreiben Sie Layout, Größen und Schließregeln in einem Prompt — zum Beispiel „ein 560px zentrierter Dialog mit scrollbarem Body, Abbrechen- und Bestätigen-Aktionen und einer destruktiven Variante, die Escape ignoriert". MeDo generiert die Komponente inklusive Fokus-Trap, Fokus-Rückgabe, Scroll-Sperre und Dialog-Semantik, sodass Sie ein funktionierendes Overlay erhalten und nicht bloß ein gestyltes div.

Was ist Fokus-Trapping und warum braucht ein Modal es?

Fokus-Trapping hält Tab und Shift+Tab in einem Zyklus durch die interaktiven Elemente im Dialog, statt in die Seite darunter zu entweichen. Ohne ihn tabbt ein Tastaturnutzer über die Bestätigen-Schaltfläche hinaus in Links, die er nicht sehen kann — verwirrend und ein WCAG-Verstoß. Der Trap sollte immer mit Fokus-Rückgabe kombiniert werden, die den Fokus beim Schließen auf das auslösende Element zurücksetzt.

Soll ein Modal beim Klick auf den Backdrop schließen?

Bei informativen Dialogen mit geringem Risiko ja — Backdrop-Klick und Escape sind die erwarteten Schließmuster. Bei destruktiven Bestätigungen und Formularen mit ungespeicherten Eingaben nein: Ein versehentlicher Klick außerhalb der Box darf keine Daten löschen oder Eingaben verwerfen. Verlangen Sie für alles Irreversible einen expliziten Schaltflächenklick.

Kann ich das native HTML-<dialog>-Element statt eines eigenen Modals nutzen?

Oft ja. Das native <dialog>-Element mit showModal() liefert Fokus-Trapping, Escape-Handling, Top-Layer-Stapelung und ein ::backdrop-Pseudoelement kostenlos, ohne z-index-Verwaltung. Body-Scroll-Sperre und Animation müssen Sie weiterhin selbst umsetzen, und ältere Browser brauchen einen Fallback. Sagen Sie MeDo, dass Sie das native Element wollen, und es baut darauf auf, statt das Verhalten nachzuimplementieren.

Wie sollte sich ein Modal auf Mobilgeräten verhalten?

Unter etwa 640px schlägt ein Bottom Sheet meist die zentrierte Karte: Es verankert die Primäraktion in Daumennähe, nutzt die volle Breite für Formularfelder und entspricht der Plattformkonvention, die Nutzer schon kennen. MeDo kann beide Layouts in einer Komponente generieren und an einem von Ihnen genannten Breakpoint umschalten.

Braucht ein Modal role="dialog" und aria-modal?

Ja, es sei denn, Sie verwenden das native <dialog>-Element, das die Semantik selbst mitbringt. Ein eigenes Overlay braucht role="dialog", aria-modal="true" und entweder aria-labelledby mit Verweis auf den sichtbaren Titel oder aria-label, wenn keine sichtbare Überschrift existiert. Ohne aria-modal geben Screenreader die Seite hinter dem Overlay weiterhin als navigierbaren Inhalt aus.