The Modal component is a dialog box or popup window that is displayed on top of the current page content. It is used to present critical information, request user input for a specific task, or show supplementary content without navigating away from the current page. When a modal is active, interaction with the underlying page content is typically disabled until the modal is dismissed or an action within it is taken.

When to use

  • For tasks that require user focus and must be completed or dismissed before interacting with the rest of the page (e.g., creating a new item, confirming a critical action like deletion, or complex user settings).
  • To display important information, warnings, or errors that need to interrupt the user's current flow and demand attention.
  • For short forms that need to be completed in context.

When not to use / alternatives

  • For very brief, non-critical notifications that don't need to interrupt the user (use Alerts or a Toast/Snackbar pattern instead).
  • If the content or task is extensive and better suited for a dedicated page (e.g., a complex multi-step wizard or very long forms).
  • For multi-step workflows that are too complex to be comfortably contained within a single modal (consider a series of distinct pages or a larger overlay/canvas if appropriate).
  • When the information is not critical and does not need to halt user interaction with the main page (consider an inline expand/collapse section, a Popover for contextual information, or a non-modal Drawer/Offcanvas).

Component anatomy

A Lighthouse Modal typically consists of the following key parts:

  • Backdrop: The semi-transparent overlay that covers the page content behind the modal. It visually de-emphasizes the underlying page and indicates that it is temporarily inactive.
  • Modal Dialog: The main container for the modal itself. This element controls the modal's size, shape, and positioning on the screen.
  • Modal Content: The visual wrapper within the Modal Dialog that holds the header, body, and footer sections. This part typically has its own background, border, and shadow.
  • Modal Header (Optional): A section at the top of the Modal Content. It usually contains the modal title and an optional close (dismiss) button.
  • Modal Title (Optional): Text that clearly describes the purpose or content of the modal.
  • Modal Body: The primary content area of the modal. This section can contain text, forms, images, lists, and other components.
  • Modal Footer (Optional): A section at the bottom of the Modal Content. It usually contains action buttons related to the modal's purpose (e.g., "Save," "Cancel," "Confirm," "Close").
  • Close Button (Optional): Typically an "X" icon, often placed in the Modal Header, or a text button in the Modal Footer, allowing the user to dismiss the modal without completing an action.

Default Modal

The standard appearance and behavior, typically including a header, body, and footer.

Sizes

Modal Sizes: Lighthouse modals can be presented in various predefined widths to suit different content needs: - Small (sm): For brief messages, simple confirmations, or very short forms. - Width Token: modal-sm (Value: {q-size-320} or 320px)   - Medium (md): The default size suitable for many common use cases. - Width Token: modal-md (Value: {q-size-580} or 580px)   - Large (lg): For modals containing more extensive content or complex forms. - Width Token: modal-lg (Value: {q-size-890} or 890px)   - Extra-Large (xl): For scenarios requiring a very wide content area within the modal. - Width Token: modal-xl (Value: {q-size-1140} or 1140px)

Alert

Alert modal

Success

Success modal

Functional Modals

Programmatically Create Modals using the useModalsUtilities composable from the NPM package.

Take a look at this advanced composable usage on QPortal: link.

Multiple modal support

Props

QModal

PropTypeDefaultDescription
modelValuebooleanrequiredControls visibility (use with v-model).
titlestring""Modal header title text.
titleHtmlstring""Modal header title as raw HTML (overrides title).
titleTag"h1"–"h6""h4"HTML tag for the title element.
size"sm" | "lg" | "xl"-Modal width.
centeredbooleanfalseVertically centers the modal in the viewport.
scrollablebooleantrueMakes the modal body scrollable when content overflows.
okTitlestring"Save"Label for the OK/confirm button.
okVariantButtonVariant"primary"Variant for the OK button.
okDisabledbooleanfalseDisables the OK button.
cancelTitlestring"Cancel"Label for the cancel button.
cancelVariantButtonVariant"outline-secondary"Variant for the cancel button.
cancelDisabledbooleanfalseDisables the cancel button.
okOnlybooleanfalseHides the cancel button, showing only the OK button.
hideHeaderbooleanfalseHides the modal header.
hideHeaderClosebooleanfalseHides the close (×) button in the header.
hideFooterbooleanfalseHides the modal footer.
noCloseOnBackdropbooleanfalsePrevents closing when clicking the backdrop.
noCloseOnEscbooleanfalsePrevents closing when pressing Esc.
noBackdropbooleanfalseRemoves the backdrop overlay.
autoCloseOnOkbooleantrueAutomatically closes the modal when OK is clicked.
imagePathstring""Optional image shown in the modal header area.
idstring""HTML id for the root element.
classstringnullAdditional CSS classes on the modal wrapper.

Events

EventPayloadDescription
update:modelValuebooleanEmitted when the modal opens or closes. Use with v-model.
click-okEmitted when the OK button is clicked.
click-cancelEmitted when the cancel button is clicked.
click-closeEmitted when the header close (×) button is clicked.
showEmitted before the modal starts to open.
shownEmitted after the modal has fully opened.
hideEmitted before the modal starts to close.
hiddenEmitted after the modal has fully closed.

Slots

SlotDescription
defaultMain body content of the modal.
modal-headerReplaces the entire default header.
modal-titleReplaces only the title text in the header.
modal-footerReplaces the entire default footer.

Accessibility

  • The modal uses role="dialog" and aria-modal="true"; the title or modal-title slot provides the accessible name via aria-labelledby
  • Focus is trapped inside the modal while it is open; Esc closes the modal and returns focus to the trigger element
  • Ensure the trigger element (e.g. a button) has a meaningful label so screen readers can announce it before the modal opens
  • When using hideHeader, provide an aria-label on the modal or a visually-hidden heading inside the default slot
  • For destructive actions (e.g. QModalConfirmDelete), use variant="danger" on the OK button to visually reinforce the risk