MeDo

Generador de Modales con IA.

Describe el diálogo que necesitas y MeDo genera todo el conjunto — encabezado, cuerpo con scroll y pie con acciones, además de captura de foco, restauración del foco al cerrar, bloqueo de scroll del body y una variante bottom sheet para móvil.

Modal
Modal

Lo difícil de un modal es la página que hay detrás

Un modal parece una caja centrada con sombra, y por eso se reconstruye mal tan a menudo. La capa visual es trivial; la parte difícil vive por completo fuera del componente. Abrir un diálogo tiene que congelar el documento que hay debajo, capturar el foco del teclado para que Tab no se escape hacia contenido oculto, ocultar el resto de la página a las tecnologías de asistencia y luego devolver el foco al elemento exacto que lo abrió. Si se omite ese último paso, un usuario de teclado vuelve en silencio al principio del documento sin saber dónde está. Generar el diálogo junto con su contrato de foco significa que esa máquina de estados es correcta en el primer render, en lugar de parchearse tras una ronda de QA.

6 plantillas

Plantillas de Modal que puedes generar

Cada plantilla es un prompt real, no una captura de pantalla. Cópialo en cualquier editor de IA o ejecútalo en MeDo y obtén código 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.

Prueba en 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.

Prueba en 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.

Prueba en 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.

Prueba en 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.

Prueba en 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.

Prueba en MeDo

Cómo personalizar tu Modal

Indica qué diálogos no deben poder descartarse

Escape y los clics en el backdrop son el valor predeterminado correcto para diálogos informativos, pero son un riesgo en confirmaciones destructivas y formularios de varios pasos con datos sin guardar. Nombra las variantes que deben ignorar ambos, para que un clic accidental fuera de la caja no borre una cuenta.

Pide restauración del foco, no solo captura del foco

La mayoría de los prompts logran la captura y olvidan el viaje de vuelta. Especifica que el foco regresa al elemento que abrió el diálogo al cerrarlo, y que el diálogo guarda esa referencia al abrirse, para que quienes usan teclado retomen exactamente donde lo dejaron.

Elige centrado o bottom sheet según el breakpoint

Un diálogo centrado en un teléfono deja los botones de acción flotando a media pantalla, lejos del pulgar. Pide un bottom sheet por debajo de 640px con la acción principal al alcance, y mantén el diseño centrado para viewports más anchos.

Nunca abras un modal dentro de otro modal

Un segundo diálogo apilado sobre el primero rompe la captura de foco, duplica el backdrop y deja ambiguo qué capa cierra Escape. Pide en su lugar contenido por pasos dentro de un solo diálogo, para que el overlay siga siendo una única capa con un solo dueño del foco.

Quién usa el componente Modal

Producto SaaS

Un diálogo de confirmación no descartable para cancelar una suscripción, con el nombre del plan repetido en el cuerpo y un botón Confirmar rojo, junto a un diálogo más ligero y descartable para invitar a un compañero de equipo.

Tienda de comercio electrónico

Un diálogo de vista rápida con imágenes del producto, un selector de talla y un botón Añadir al carrito, renderizado como bottom sheet en teléfonos para que las tallas y el botón del carrito queden al alcance del pulgar.

Panel o herramienta de administración

Una confirmación de borrado masivo que indica el número exacto de registros y exige escribir el nombre del recurso antes de habilitar Confirmar, junto a un diálogo de edición cuyo formulario largo hace scroll entre un encabezado y un pie fijos.

Sitio de contenido o medios

Un diálogo lightbox para imágenes a tamaño completo con navegación por teclas de flecha, Escape para cerrar y el foco volviendo a la miniatura que lo abrió, para no perder nunca la posición de lectura en la galería.

Patrones de Modal para distintos sitios web

El mismo componente modal, adaptado al tipo de sitio donde se publica.

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.

Estilos y variantes de Modal

Elige la variante que encaje con el resto de la página y genérala.

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 en React, Next.js, Vue y Svelte

React, Next.js, Vue 3, SvelteKit, Astro o HTML puro: el mismo modal, seis formas de integrarlo.

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

Cómo añadir tu Modal a un proyecto

Cuatro pasos, desde elegir una plantilla de modal hasta llevarlo a producción.

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.

Preguntas frecuentes sobre Modal

¿Cómo genero un componente modal con IA?

Describe el layout, los tamaños y las reglas de cierre en un solo prompt — por ejemplo "un diálogo centrado de 560px con cuerpo con scroll, acciones Cancelar y Confirmar, y una variante destructiva que ignora Escape". MeDo genera el componente con captura de foco, restauración del foco, bloqueo de scroll y semántica de diálogo incluidas, así obtienes un overlay funcional y no un div con estilos.

¿Qué es la captura de foco y por qué la necesita un modal?

La captura de foco mantiene Tab y Shift+Tab ciclando entre los elementos interactivos del diálogo en lugar de escapar a la página de debajo. Sin ella, quien navega con teclado pasa del botón Confirmar a enlaces que no puede ver, lo cual es confuso y un incumplimiento de WCAG. La captura debe ir acompañada de la restauración del foco, devolviéndolo al elemento disparador cuando el diálogo se cierra.

¿Debe cerrarse un modal al hacer clic en el backdrop?

En diálogos informativos y de bajo riesgo, sí — el clic en el backdrop y Escape son los patrones de cierre que la gente espera. En confirmaciones destructivas y formularios con datos sin guardar, no: un clic accidental fuera de la caja no debería borrar datos ni descartar lo escrito. Exige pulsar un botón explícito para cualquier cosa irreversible.

¿Puedo usar el elemento nativo <dialog> de HTML en lugar de un modal propio?

A menudo sí. El elemento nativo <dialog> con showModal() te da captura de foco, manejo de Escape, apilado en la top layer y un pseudoelemento ::backdrop gratis, sin gestionar z-index. Aún tienes que bloquear el scroll del body y animarlo tú mismo, y los navegadores antiguos necesitan un fallback. Dile a MeDo que quieres el elemento nativo y construirá sobre él en lugar de reimplementar el comportamiento.

¿Cómo debería comportarse un modal en móvil?

Por debajo de unos 640px, un bottom sheet suele superar a la tarjeta centrada: ancla la acción principal cerca del pulgar, usa todo el ancho para los campos del formulario y coincide con la convención de plataforma que los usuarios ya conocen. MeDo puede generar ambos layouts en un componente y alternarlos en el breakpoint que indiques.

¿Un modal necesita role="dialog" y aria-modal?

Sí, salvo que uses el elemento nativo <dialog>, que aporta la semántica por sí mismo. Un overlay propio necesita role="dialog", aria-modal="true" y bien aria-labelledby apuntando al título visible o aria-label cuando no hay encabezado visible. Sin aria-modal, los lectores de pantalla siguen exponiendo la página de detrás del overlay como contenido navegable.