본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Overlay 마스크

원문 보기 위키 갱신

Overlay는 화면 위에 마스크 레이어를 만드는 컴포넌트예요. 주로 사용자가 다른 작업을 하지 못하게 막을 때 쓰죠.

출처: 문서

설치

@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.

import { createApp } from 'vue'
import { Overlay } from '@nutui/nutui'

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

사용 예시

기본 사용법

visible로 마스크의 표시/숨김을 제어해요.

demo: overlay basic

마스크 스타일

overlay-style로 설정할 수 있어요.

demo: overlay mask

애니메이션 시간 설정

duration으로 마스크 표시/숨김 시간을 정해요. 단위는 s(초)예요.

demo: overlay duration

배경 스크롤 잠금

lock-scroll로 마스크가 표시됐을 때 배경을 잠가 스크롤을 금지할지 정해요.

demo: overlay lock

콘텐츠 중첩

기본 slot을 지원해서 어떤 콘텐츠든 중첩할 수 있어요.

demo: overlay nest

마스크 클릭해도 닫지 않기

close-on-click-overlay로 마스크를 클릭했을 때 닫히는지 제어해요. 원문 기준으로는 true로 설정하면 click 이벤트도 동작하지 않게 돼요.

demo: overlay close

API

Props

Attribute Description Type Default
v-model:visible Control the display/hide of masks boolean false
z-index Custom Mask Level string | number 2000
duration Display/hide animation duration, in seconds string | number 0.3
overlay-class Custom mask class name string -
overlay-style Custom Mask Style CSSProperties -
lock-scroll Whether the background is locked when the mask is displayed boolean true
close-on-click-overlay Whether to close the mask when clicking. boolean true

Events

Event Description Arguments
click Triggered when clicked. event: MouseEvent

Slots

Name Description
default Embedded Mask Content Customization

Types v4.3.8

이 컴포넌트는 아래 타입 정의를 함께 내보내요.

import type {
  OverlayProps,
  OverlayInstance
} from '@nutui/nutui';

Theming

CSS Variables

스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.

Name Default Value
--nut-overlay-bg-color rgba(0, 0, 0, 0.7)

더 알아보기 (Learn more)