Saltar al contenido
DS

Componentes · Interacción

Diálogo <Dialog>

Ventana modal nativa: bloquea el scroll, atrapa el foco y se cierra con Esc.

import Dialog from '@vivla-cms/ds/primitives/Dialog.astro'

Ejemplos

Cuatro tamaños

Cualquier elemento con data-ds-dialog-open="<id>" abre el diálogo con ese id. sm es el ancho de lectura, md 48rem, lg el ancho de página y full toda la pantalla. Se cierra con la X, con Esc o pulsando fuera; el foco vuelve al botón que lo abrió y la página de detrás no se mueve.

Todo lo que incluye la casa

Piscina, jardín, chimenea, cocina abierta, wifi, aire acondicionado y parking para dos coches.

Limpieza y mantenimiento los hace VIVLA entre estancia y estancia.

Todo lo que incluye la casa

Piscina, jardín, chimenea, cocina abierta, wifi, aire acondicionado y parking para dos coches.

Limpieza y mantenimiento los hace VIVLA entre estancia y estancia.

Todo lo que incluye la casa

Piscina, jardín, chimenea, cocina abierta, wifi, aire acondicionado y parking para dos coches.

Limpieza y mantenimiento los hace VIVLA entre estancia y estancia.

Salón de la casa con vistas al mar

El tema del panel

theme pinta el panel, no hereda el de la banda: un diálogo abierto desde una banda terracota sigue siendo claro salvo que pidas otro. dark es el de las galerías y vídeos. Sin título visible, pon label para que tenga nombre accesible.

Panel claro

Compra de 1/8 a 1/2 de una casa y disfrútala unas seis semanas al año por cada octavo.

Panel papel

Compra de 1/8 a 1/2 de una casa y disfrútala unas seis semanas al año por cada octavo.

Panel oscuro

Compra de 1/8 a 1/2 de una casa y disfrútala unas seis semanas al año por cada octavo.

Panel terracota

Compra de 1/8 a 1/2 de una casa y disfrútala unas seis semanas al año por cada octavo.

Panel cobalto

Compra de 1/8 a 1/2 de una casa y disfrútala unas seis semanas al año por cada octavo.

Botones propios para cerrar

Cualquier elemento con data-ds-dialog-close dentro del diálogo lo cierra. Con closeOnBackdrop={false} un clic fuera no lo cierra: úsalo cuando cerrar por accidente haga perder algo.

¿Enviamos tu solicitud?

Te llamaremos en menos de 24 horas para contarte qué casas hay disponibles.

Modal de lead

size="lead" es el modal de los formularios cortos del hand-off (ficha «Especificaciones», /listings «¿Qué casa buscas?»): panel blanco de 640, padding 40 · 40 · 48 · 48, el aspa de 32 sola en su fila arriba a la derecha y velo espresso al 50 %. El título va a 40/42 y el contenido 16 por debajo. En el móvil ocupa toda la pantalla.

Recibe las especificaciones

Déjanos tus datos y te enviamos la ficha completa de Casa Taula: planos, calidades y amenities.

Props

Props de Dialog
Prop Valores Por defecto Para qué
id * string — Element id; triggers point at it with data-ds-dialog-open="<id>".
title string — Visible heading (h2 element at h3 size); also the accessible name.
label string — Accessible name when there is no visible title.
description string — A muted line under the title; also the dialog's description (aria-describedby).
size smmdlgfullleadside 'sm' —
theme lightdarkaccentinvestpapersoft — Default light; paper (white) for size="lead" and size="side".
closeOnBackdrop boolean true Close on a click outside the panel (default true).
scrim defaultlead 'default' The veil: default 60 % espresso (90 % surface when dark) · lead = the lead modals' 50 % espresso (always on size="lead" and size="side").
data-* string | undefined — Se pasan tal cual al elemento.
aria-* string | undefined — Se pasan tal cual al elemento.

Slots: contenido

Notas del código

El comentario de cabecera de Dialog.astro, tal cual (en inglés, como el código): si cambia el código, cambia esto.

modal window on the native <dialog> (showModal), roles only. Shared by the video lightboxes (testimonials, FAQ videos), the ficha amenities list and the gallery lightbox.

<Button variant="ghost" data-ds-dialog-open="amenities" aria-haspopup="dialog">Ver todos</Button>
<Dialog id="amenities" title="Todo lo que incluye la casa">…</Dialog>

Opening: any element with data-ds-dialog-open="<id>" (delegated, so it also works for content added later; a modified click on a link trigger keeps the browser's new-tab behaviour), or dialog.showModal() from a script. Both paths get the same behaviour:

  • Focus: the browser moves focus into the dialog (the close button comes
first; put `autofocus` on another control to start there). Tab and
Shift+Tab cycle inside the dialog. On close, focus returns to the
element that opened it: the trigger, or for a script opener the control
the visitor last pressed or focused (recorded on pointerdown, click and
focusin, so Safari, which does not focus a clicked button, gets it too).
  • Esc closes (native cancel). A click on the backdrop closes it too
(press AND release outside the panel, so a text selection that ends
outside does not), unless `closeOnBackdrop={false}`.
  • Scroll lock: the page behind does not scroll while any Dialog is open
(`overflow: hidden` on <html>, scrollbar gutter kept so nothing shifts).
It comes from `lib/scroll-lock.ts`, shared with the site menu's own
<dialog>, and counts locks — overlapping overlays release the page once.
  • Close button: top-right (bottom-right belongs to the cookie consent
button), 44 px, named by `uiLabel('dialogClose')`. It stays in view: a
sticky corner in sm/md/lg (it follows long content down), fixed to the
viewport corner in `full`. It is a plain `type="button"` (no nested
<form method="dialog">), so a Dialog can live inside a filter <form>
without the X submitting it. Any element with `data-ds-dialog-close`
inside the dialog closes it too (only its own dialog when nested).
  • Events: ds-dialog:open (bubbles) fires on the <dialog> once it is open;
the native `close` event fires when it closes (clear a player's src there).

Name: title renders a visible h2 (h3 size) and labels the dialog; without a visible title pass label (e.g. a lightbox). The close corner is kept clear either way: the title leaves room on its right, and a label-only sm/md/lg dialog starts its content below the button. In full the button floats over the content's top-right corner. theme sets the palette of the panel (default light, so a dialog opened from a terracotta band does not turn terracotta); dark suits media lightboxes.

Sizes: sm = prose (--container-prose, 36.5625rem = 585 px, five Figma columns) · md = 48rem · lg = --container-shell (1432, the content of the 1512 canvas; a dialog keeps that size on wider screens, the page column does not) · full = the whole viewport with no panel padding (the panel shrinks to its content and the empty area around it is backdrop). class goes on the panel.

lead = the lead modals of the 30/10 hand-off (ficha «Especificaciones» 1612:3342 / 3732 / 4049, listings «¿Qué casa buscas?» 1606:3072 / 1610:3003 / 1610:3299): a 640 px white panel (paper theme unless theme says otherwise), padding 40 top · 40 right · 48 bottom · 48 left, a bare line/close 32 in its own row at the top right (no disc) with the content right under it, and a 50 % espresso scrim (on-surface/50). Its title is typography-01-2XL (title, 40/42) with the slot 16 below. Phones (not drawn): the panel fills the screen, px-gutter, the same row on top.

scrim="lead" gives another size that same 50 % veil: the ficha's «¿Hablamos?» card (LeadDialog look="card", 1721:7538) is a full dialog drawn over a 50 % espresso page, not the default 60 %.

<Dialog id="listing-specs" size="lead" title="Recibe las especificaciones">
  <Text>Déjanos tus datos y te enviamos la ficha completa…</Text>
  <LeadForm … />
</Dialog>

side = the side panel of the 06/11 hand-off (ficha «Calidades y amenities», «PDP — Amenities · Sidebar · Desktop» 1917:6547, panel 1917:6633): a white panel (paper unless theme says otherwise) docked to the right edge, full height, 560 px from md, over the lead modals' 50 % espresso scrim. Its header — title (typography-01-2XL, 40/42) with the bare 32 px line/close on the same row, then description — stays put while the slot scrolls under it. Padding 64 · 40 · 24 over the header, 16 · 40 · 40 around the slot. It slides in from the right (still with reduced motion). Phones (not drawn): the whole screen, px-gutter.

<Dialog id="listing-amenities" size="side" title="Calidades y amenities" description="16 amenities en esta casa">…</Dialog>

description is a line in the muted body under the title (any size); it also describes the dialog (aria-describedby).

Dónde se usa

17 veces en 13 archivos de la web y los bloques del CMS.

Ver los archivos
esc