Skip to content

MazDialog ​

MazDialog is a standalone dialog component to show important informations to the user or propose specific action. Many options are available. You can hide the header or the footer, full-size layout, differents states etc.

Before use it, you should install the MazUi plugin in your project, follow instructions in Getting Started

TIP

This component uses <Teleport to="body"> with MazBackdrop, so you can implement this component anywhere and it inherits all its props

Basic usage ​

Scrollable ​

For long content, you can enable scrolling in content part (Header and footer slot remain visible at top and bottom)

Width ​

On tablet and up, the dialog is sized by two CSS variables coming from the active theme preset (components.dialog):

  • --maz-dialog-max-width (default 38rem)
  • --maz-dialog-min-width (default 32rem)

You can set these defaults globally per preset — see the theme components.dialog documentation. To change the width of a single dialog, pass the max-width / min-width props — they always override the preset:

TIP

The default widths are expressed in rem, so they scale with the preset's base-font-size. Presets with a larger base size (e.g. ocean at 16px) ship rem values adjusted to keep the rendered pixel width consistent across presets.

Accessibility ​

  • The dialog is a modal dialog (aria-modal), labelled by its title and described by its content (override them with the aria-labelledby / aria-describedby props).
  • The focus moves into the dialog on open, stays trapped inside and goes back to the previous element on close. Esc closes it (close-on-escape).
  • While it is open, the rest of the page is inert (no focus, no click, hidden from assistive technologies), except the toasts and the live regions.

Props ​

NameDescriptionTypeRequiredDefaultPossible values
model-valuev-model Modal's model valuebooleanNo--
titleTitle of the modal in headerstringNo--
hide-close-buttonRemove the close button in headerbooleanNo--
max-widthModal's max-width.stringNo"var(--maz-dialog-max-width, 38rem)"-
min-widthModal's min-width.stringNo"var(--maz-dialog-min-width, 32rem)"-
scrollableModal's content becomes scrollable - warning: a overflow is appliedbooleanNo--
persistentPersistent dialog (not closable by clicking outside and remove close button)booleanNo--
teleport-selectorTeleport selectorstringNo--
before-closeFunction called before modal is close(() => void | Promise<void>)No--
close-on-escapePrevent close on escape keybooleanNotrue-
transition-nameTransition namestringNo--
backdrop-classBackdrop classClassValueNo--
backdrop-content-classBackdrop content classClassValueNo--
content-paddingAdd padding to the contentbooleanNo--
justifyJustify content"none" | "center" | "end" | "start" | "space-between" | "space-around"No-'none' | 'center' | 'end' | 'start' | 'space-between' | 'space-around'
alignAlign content"none" | "center" | "end" | "start"No-'none' | 'center' | 'end' | 'start'
variantVariant"bottom-sheet" | "dialog" | "drawer"No-'bottom-sheet' | 'dialog' | 'drawer'
aria-labelledbyID for aria-labelledbystringNo--
aria-describedbyID for aria-describedbystringNo--

Events ​

Event namePayloadDescription
update:model-valuevalue: booleanemitted when modal is open or close
openvalue?: void | undefinedemitted when modal is open
closevalue?: void | undefinedemitted when modal is close

Slots ​

NameDescriptionBindings
headerHeader slotclose () => void - close function
titleTitle slot in the header-
defaultDefault contentclose () => void - close function
footerFooter slotclose () => void - close function

Expose ​

close ​

Close the dialog