Modal

Content overlay without leaving the page

stable v1.0.0

Preview

The real canon modal: backdrop, focus trap, close via Escape / backdrop click / "Close" button, locked scroll and Lenis stop/start. The trigger is a <button> with data-modal pointing to the id.

Props

PropTypeNote
idstringRequired. Triggers use data-modal="id".
titlestringRequired. Rendered as <p>, not a heading.
image, imageAltstringOptional. One image at most, on top, clipped to the panel corners.
metadatastringOptional. Inline with "·".
closeLabelstringDefault "Cerrar" (this page passes "Close").
slot bodyn/aBody paragraphs (3 at most).

Anatomy

ElementFamilyDesktopMobile
Backdropn/a#000 at 60%Same
Paneln/amax-width 720px, radius 16pxSame
TitleAleo28px / 40022px
BodyGeorama16px / 40016px
MetadataGeorama12px / 400, secondary (--text-caption)12px
Close buttonAleoText label, 18px, bottom-rightFull width, centered

Behavior

ActionAnimation
OpenBackdrop + panel fade in, panel scale 0.98→1, 0.3s ease-out
CloseFade out 0.2s ease-in
Ways to closeBackdrop click, "Close" button, Escape key

Body scroll is locked. Focus is trapped inside the modal. Lenis stop/start.

Constraints

  • Three body paragraphs at most.
  • One image at most. No gallery.
  • No forms, no video, no nested modals.
  • No navigation between modals.
  • No URL change. Modals are ephemeral.
  • display: none when closed, not opacity: 0 (avoids preloading images).

Decisions

DecisionWhy
A "Close" text label, not a × iconTypographic approach. More explicit.
Close at the bottom, not top-rightThe reader finishes the content and finds the way out
Max 3 paragraphsForces curation. Long content deserves its own page
display:none, not opacity:0Stops the browser from preloading images in hidden modals
<button> as trigger, not <a>Modals don't navigate. An <a> with an empty href fails accessibility