--- title: "MazBackdrop" description: "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." package: "maz-ui" url: "https://maz-ui.com/components/maz-backdrop" --- # 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. - Package: `maz-ui` - Import: `import MazBackdrop from 'maz-ui/components/MazBackdrop'` - Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app - Web: https://maz-ui.com/components/maz-backdrop > Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md) **Tip:** This component uses `` and is the foundation for [MazDialog](./maz-dialog.md), [MazDrawer](./maz-drawer.md), and [MazBottomSheet](./maz-bottom-sheet.md) ## 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. ```vue ``` ## Persistent backdrop A persistent backdrop cannot be closed by clicking outside or pressing Escape. Perfect for important confirmations! ```html

I'm persistent!

You can only close me by clicking the button below

Force Close
``` ## 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! ```html

I'm at the top left!

Close

I'm perfectly centered!

Close

I'm at the bottom right!

Close
``` ## Custom animations MazBackdrop comes with built-in animations, but you can customize them with the `transition-name` prop. ```html

I slide and scale in!

This uses the same animation as MazDialog

Close
``` ## 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! ## MazBackdrop API `import MazBackdrop from 'maz-ui/components/MazBackdrop'` ### Props - `model-value` (`boolean`, default: `false`, `v-model`): Modal's model value. - `teleport-selector` (`string`, default: `"body"`): Teleport selector. - `before-close` (`(() => void | Promise)`): Function called before modal is close. - `persistent` (`boolean`, default: `false`): Persistent dialog (not closable by clicking outside and remove close button). - `close-on-escape` (`boolean`, default: `true`): Prevent close on escape key. - `transition-name` (`string`, default: `"backdrop-anim"`): Transition name. - `backdrop-class` (`ClassValue`): Backdrop class. - `backdrop-content-class` (`ClassValue`): Backdrop content class. - `content-padding` (`boolean`, default: `false`): Add padding to the content. - `justify` (`"none" | "center" | "end" | "start" | "space-between" | "space-around"`, default: `"none"`): Justify content. - `align` (`"none" | "center" | "end" | "start"`, default: `"none"`): Align content. - `variant` (`"bottom-sheet" | "dialog" | "drawer"`): Variant. - `aria-labelledby` (`string`): ID for aria-labelledby. - `aria-describedby` (`string`): ID for aria-describedby. ### Events - `@update:model-value` (payload: `value: boolean`): Emitted when modal is open or close - `@open` (payload: `value?: void | undefined`): Emitted when modal is open - `@close` (payload: `value?: void | undefined`): Emitted when modal is close - `@before-close` (payload: `value?: void | undefined`): Emitted before modal is close ### Slots - `#default`: Place your content here Bindings: `close: () => void` (close function). ### Exposed (template ref) - `onBackdropAnimationLeave`: Animation leave event - `close`: Close the backdrop - `present`: The present state of the backdrop - `toggleModal`: Toggle the backdrop - `onKeyPress`: Key press event