MazBackdrop
MazBackdrop is a flexible backdrop component that provides a foundation for modals, drawers, bottom sheets and any overlay content. It handles focus management, keyboard navigation, and animations automatically.
TIP
This component uses <Teleport to="body">
and is the foundation for MazDialog, MazDrawer, and MazBottomSheet
Basic usage
MazBackdrop creates a semi-transparent overlay that covers the entire screen. Think of it like a dark blanket that appears behind your content to make it stand out.
Persistent backdrop
A persistent backdrop cannot be closed by clicking outside or pressing Escape. Perfect for important confirmations!
Content positioning
You can control where your content appears using justify
and align
props. It's like choosing where to place a sticker on your screen!
Custom animations
MazBackdrop comes with built-in animations, but you can customize them with the transition-name
prop.
Accessibility features
MazBackdrop automatically handles:
- Focus trap: Tab navigation stays within your content
- Keyboard support: Escape key to close (unless persistent)
- Screen readers: Proper ARIA attributes for accessibility
- Scroll lock: Prevents background scrolling when open
These features work automatically - you don't need to do anything extra!
Props
Name | Description | Type | Required |
---|---|---|---|
model-value | v-model | boolean | No |
teleport-selector | Teleport selector | string | No |
before-close | Function called before modal is close | TSFunctionType | No |
persistent | Persistent dialog (not closable by clicking outside and remove close button) | boolean | No |
close-on-escape | Prevent close on escape key | boolean | No |
transition-name | Transition name | string | No |
backdrop-class | Backdrop class | Native type | No |
backdrop-content-class | Backdrop content class | Native type | No |
content-padding | Add padding to the content | boolean | No |
justify | Justify content | "center" | "end" | "start" | "space-between" | "space-around" | "none" | No |
align | Align content | "center" | "end" | "start" | "none" | No |
variant | Variant | "bottom-sheet" | "dialog" | "drawer" | No |
aria-labelledby | ID for aria-labelledby | string | No |
aria-describedby | ID for aria-describedby | string | No |
Events
Event name | Properties | Description |
---|---|---|
open | Emitted when modal is open | |
close | Emitted when modal is close | |
update:model-value | value boolean - The value of the model | Emitted when modal is open or close |
before-close | Emitted before modal is close |
Slots
Name | Description | Bindings |
---|---|---|
default | Place your content here | close Function - close function |
Expose
onBackdropAnimationLeave
Animation leave event
@description
This is used to handle animation leave events
close
Close the backdrop
@description
This is used to close the backdrop
present
The present state of the backdrop
@description
This is used to check if the backdrop is present (open)
toggleModal
Toggle the backdrop
@description
This is used to toggle the backdrop@param
The value to toggle the backdrop (optional)
onKeyPress
Key press event
@description
This is used to handle key press events