Modal

Centered dialog with a title, body and optional footer slot. The size prop (xs, sm, md, lg, xl) sets the dialog width and padding.

Jump to API reference

Import

Vue
import { UiModal } from '@ziyarago/ui/vue'

Basic

Vue
<UiModal title="Trip details" :open="open" @close="open = false">
  Umrah package, 10 nights: 5 in Makkah, 5 in Madinah. Flights and transfers included.
</UiModal>

With footer

Vue
<UiModal title="Share itinerary" :open="open" @close="open = false">
  Send the full day-by-day plan to your group.
  <template #footer>Footer actions go here</template>
</UiModal>

With a DatePicker

Vue
<UiModal title="Schedule pickup" :open="open" @close="open = false">
  <div
    :style="{ overflow: 'auto', maxHeight: '160px', display: 'flex', flexDirection: 'column', gap: '12px' }"
  >
    <UiSelect
      label="Hotel"
      v-model="value"
      :options="[{ value: 'a', label: 'Makkah Clock Tower' }, { value: 'b', label: 'Madinah Oberoi' }]"
     />
    <UiDatePicker label="Pickup date" v-model="value" />
  </div>
</UiModal>

Sizes

Vue
<UiModal
  size="lg"
  title="Trip details"
  :open="open"
  @close="open = false"
>
  Pick xs (320px) up to xl (720px) wide; the demo shows lg.
</UiModal>

API reference

Centered dialog with a title, close button, body and optional footer; use for forms and focused tasks that block the page.

Props

PropType and valuesDefaultDescription
openbooleanfalseShows the dialog when true; renders nothing when false.
titlestring—Header text and aria-label of the dialog.
subtitlestring—Muted line under the title in the header.
closablebooleantruefalse hides the close (x) button in the header.
closeOnBackdropbooleantruefalse ignores clicks on the scrim.
closeOnEscbooleantruefalse ignores the Escape key (focus trap stays active).
widthstring | number—CSS max-width of the dialog, for example "960px" (a number is pixels). Overrides the width of size.
sizexssmmdlgxl2xl3xl4xl5xl'md'Max width, padding and text: xs 320, sm 420, md 520, lg 640, xl 720, 2xl 768, 3xl 896, 4xl 1024, 5xl 1280 px (always at most the screen width). An unknown value falls back to md and warns in development. width overrides the max width.

Slots

Vue: named slots. React: a prop with the same name; default is children.

defaultDialog body.
footerFooter area, usually action buttons. Rendered only when provided.
titleReplaces the title prop with custom header content.
subtitleReplaces the subtitle prop.

Events

Vue: @name. React: onName.

closeCalled on the close button, a click on the scrim or the Escape key. Set open to false in the handler.

Notes

  • Has role="dialog" and aria-modal. Escape calls close; on open focus moves into the dialog, Tab is trapped inside it and focus returns to the previously focused element on close.
  • Put data-autofocus on an element to choose which one receives initial focus (default: first focusable).
  • Closed state renders nothing, so inner state is lost on close.