import{o as a,a as t,y as n}from"./vue-libs.b44bc779.js";const e={class:"van-doc-markdown-body"},l=n(`

Overlay

Intro

Create a mask layer to emphasize specific page elements and prevent users from performing other operations.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

import { createApp } from 'vue';
import { Overlay } from 'vant';

const app = createApp();
app.use(Overlay);

Usage

Basic Usage

<van-button type="primary" text="Show Overlay" @click="show = true" />
<van-overlay :show="show" @click="show = false" />
import { ref } from 'vue';

export default {
  setup() {
    const show = ref(false);
    return { show };
  },
};

Embedded Content

<van-overlay :show="show" @click="show = false">
  <div class="wrapper" @click.stop>
    <div class="block" />
  </div>
</van-overlay>

<style>
  .wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .block {
    width: 120px;
    height: 120px;
    background-color: #fff;
  }
</style>

API

Props

AttributeDescriptionTypeDefault
showWhether to show overlaybooleanfalse
z-indexz-indexnumber | string1
durationAnimation durationnumber | string0.3
class-nameClassNamestring-
custom-classCustom styleobject-
lock-scrollWhether to lock background scrollbooleantrue
lazy-render v3.4.2Whether to lazy render util appearedbooleantrue

Events

EventDescriptionArguments
clickEmitted when component is clickedevent: MouseEvent

Slots

NameDescription
defaultDefault slot

Types

The component exports the following type definitions:

import type { OverlayProps } from 'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-overlay-z-index1-
--van-overlay-background-colorrgba(0, 0, 0, 0.7)-
`,13),p=[l],i={__name:"README",setup(d,{expose:s}){return s({frontmatter:{}}),(r,o)=>(a(),t("div",e,p))}};export{i as default};