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

Popover

원문 보기 위키 갱신

Popover (팝오버)

요소를 클릭하거나 호버했을 때 버블 카드를 띄워 덮어 보여 주는 컴포넌트예요. 메뉴 목록을 담을 수도 있고, 슬롯으로 완전히 다른 콘텐츠를 담을 수도 있어요.

출처: 문서

본문

소개 (Intro)

요소를 클릭하거나 호버해서 버블 카드 오버레이를 띄워요.

설치 (Install)

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

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

기본 사용법 (Basic Usage)

Popover는 라이트 스타일과 다크 스타일을 모두 지원해요. 기본은 라이트 스타일이고, theme 속성을 dark로 설정하면 다크 스타일로 바뀌어요.

demo: popover basic

옵션 설정 (Option Configuration)

list 배열에서 옵션의 disabled 필드로 해당 옵션을 비활성화할 수 있어요.

demo: popover option

커스텀 콘텐츠 (Custom Content)

content라는 이름의 슬롯으로 내용을 커스터마이즈해요.

demo: popover content

위치 (Position)

location 속성으로 버블이 튀어나올 위치를 조절해요. 선택 가능한 값은 다음과 같아요.

top           # Top middle
left          # Left middle
right         # Right middle
bottom        # Bottom middle
top-start     # Top left
top-end       # Top right
left-start    # Left top
left-end      # Left bottom
right-start   # Right top
right-end     # Right bottom
bottom-start  # Bottom left
bottom-end    # Bottom right

demo: popover position

커스텀 타깃 (Custom Target)

Popover는 targetId 속성을 제공해요. 타깃 요소에 해당 id 값을 지정해 두면 그 요소를 타깃으로 삼을 수 있어요.

demo: popover target

커스텀 색상 (Custom Color)

demo: popover color

API

Props

Attribute Description Type Default
list list of options List[] []
visible whether to show boolean false
theme Theme style, can be set to dark light string light
location pop-up location string bottom
offset the offset of the occurrence position [number,number] [0, 12]
show-arrow whether to show small arrows boolean true
custom-class custom class string ''
duration Transition duration,Unit second number | string 0.3
overlay Whether to show overlay boolean false
overlay-class Custom overlay class string ''
overlay-style Custom overlay style string ''
close-on-click-overlay Whether to close when clicking overlay boolean true
close-on-click-action Whether to close when clicking action boolean true
close-on-click-outside Whether to close when clicking outside boolean true
bg-color Custom color string -
target-id Custom target id string -
arrow-offset the offset of the arrow number 0

List 데이터 구조 (List data structure)

list 속성은 객체 배열이에요. 배열의 각 객체가 한 컬럼을 설정하고, 객체에는 다음 값들을 넣을 수 있어요:

Key Description Type Default
name option text string -
icon @nutui/icons-vue name VNode -
disabled whether to disable boolean false
className Add extra class names for corresponding options string | Array | object -

Slots

Name Description
content Customize Bubble Component Menu Content
reference The content of the element that triggers the Popover to display

Events

Event Description
choose Triggered when an option is clicked
open Triggered when the menu is opened
close Fired when the menu is closed

Theming

CSS Variables

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

Name Default Value
--nut-popover-white-background-color rgba(255, 255, 255, 1)
--nut-popover-dark-background-color rgba(75, 76, 77, 1)
--nut-popover-border-bottom-color rgba(229, 229, 229, 1)
--nut-popover-primary-text-color rgba(51, 51, 51, 1)
--nut-popover-disable-color rgba(154, 155, 157, 1)
--nut-popover-menu-item-padding 8px 0
--nut-popover-menu-item-margin 0 8px
--nut-popover-menu-name-line-height normal

더 알아보기 (Learn more)