문서 오버레이

UIPopover

트리거 옆에 작업 영역을 표시합니다.

기본 사용법

재고 표에 표시할 열 선택

열 표시를 눌러 재고나 보관 위치를 켜고 끕니다. 팝오버를 열어 둔 채 바뀐 표를 확인하고 완료로 닫습니다.

상품 재고
상품재고보관 위치
노트48개A-02
펜 세트16개B-04
<script setup lang="ts">
import { UIButton, UICheckboxGroup, UIPopover } from "@connextable/ui";
import { ref, useId } from "vue";

const titleID = useId();
const columns = [
  { value: "quantity", label: "재고" },
  { value: "location", label: "보관 위치" },
];
const visibleColumns = ref<readonly string[]>(["quantity", "location"]);
const products = [
  { name: "노트", quantity: 48, location: "A-02" },
  { name: "펜 세트", quantity: 16, location: "B-04" },
];
</script>

<template>
  <div class="inventory">
    <div class="inventory__toolbar">
      <strong :id="titleID">상품 재고</strong>
      <UIPopover
        trigger-label="열 표시"
        title="표시할 열"
        side="bottom"
        align="end"
      >
        <template #body="{ close }">
          <UICheckboxGroup
            v-model="visibleColumns"
            :options="columns"
            label="표시할 열"
          />
          <UIButton size="sm" @click="close()">완료</UIButton>
        </template>
      </UIPopover>
    </div>
    <table :aria-labelledby="titleID">
      <thead>
        <tr>
          <th scope="col">상품</th>
          <th v-if="visibleColumns.includes('quantity')" scope="col">재고</th>
          <th v-if="visibleColumns.includes('location')" scope="col">
            보관 위치
          </th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="product in products" :key="product.name">
          <th scope="row">{{ product.name }}</th>
          <td v-if="visibleColumns.includes('quantity')">
            {{ product.quantity }}개
          </td>
          <td v-if="visibleColumns.includes('location')">
            {{ product.location }}
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<style scoped>
.inventory {
  inline-size: min(100%, 24rem);
}

.inventory__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-sm);
  margin-block-end: var(--ui-space-sm);
}

.inventory table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--ui-font-size-body-sm);
}

.inventory th,
.inventory td {
  padding: var(--ui-space-sm);
  border-block-end: 1px solid var(--ui-color-divider);
  text-align: start;
}

.inventory thead {
  background: var(--ui-color-surface-muted);
}
</style>

설정과 동작

팝오버 열기 버튼의 아이콘

trigger-icon에 Vue 컴포넌트를 전달해 기본 열기 버튼의 라벨 앞에 표시합니다.

네 방향과 화살표

각 버튼을 눌러 방향에 따라 화살표가 트리거 쪽을 가리키는지 확인합니다.

트리거 끝에 정렬

side와 align을 함께 지정해 팝오버를 트리거의 아래쪽 끝에 맞춥니다.

바깥 클릭 시 열림 유지

바깥을 눌러도 열린 상태를 유지하고 완료 버튼으로 닫습니다.

조합과 확장

팝오버 안에서 긴 목록 스크롤

리전 목록을 스크롤해 항목을 선택합니다. 제목과 완료 버튼은 같은 자리에 있습니다.

포털로 이동

트리거 옆에 정렬하면서 콘텐츠는 포털에 렌더링합니다.

기준 요소를 따로 지정

열기 버튼과 별개로 배지에 맞춰 팝오버를 배치합니다.

구성 컴포넌트

팝업과 위치

UIPopoverAnchor

떠 있는 콘텐츠의 위치를 계산할 때 기준이 되는 요소입니다.

기준 요소를 따로 지정 예제
UIPopoverPortal

콘텐츠를 현재 DOM 계층 밖의 포털 대상으로 옮깁니다.

포털로 이동 예제
UIPopoverContent

트리거 또는 현재 값에 연결된 콘텐츠를 담습니다.

네 방향과 화살표 예제
UIPopoverArrow

팝업이 어떤 트리거에 붙어 있는지 시각적으로 나타냅니다.

네 방향과 화살표 예제

탐색과 동작

UIPopoverTrigger

컨트롤을 실행하거나 콘텐츠를 여는 버튼입니다.

네 방향과 화살표 예제
UIPopoverClose

열린 콘텐츠를 닫습니다.

바깥 클릭 시 열림 유지 예제

값과 상태 표시

UIPopoverTitle

콘텐츠의 제목을 표시하고 접근성 이름으로 연결합니다.

네 방향과 화살표 예제
UIPopoverDescription

콘텐츠의 목적이나 추가 설명을 연결합니다.

네 방향과 화살표 예제

주요 API

속성과 모델

trigger-label타입string | undefined

기본 트리거 버튼의 텍스트입니다.

팝오버 열기 버튼의 아이콘 예제
trigger-icon타입Component

기본 열기 버튼의 텍스트 앞에 표시할 아이콘입니다.

팝오버 열기 버튼의 아이콘 예제
side타입RectSide | undefined

팝오버가 놓일 방향입니다.

네 방향과 화살표 예제
align타입RectAlign | undefined

기준 요소에 맞춰 정렬할 위치입니다.

트리거 끝에 정렬 예제
close-on-interact-outside타입boolean | undefined

기본값은 true입니다. 바깥을 눌렀을 때 열린 상태를 유지하려면 false를 지정합니다.

바깥 클릭 시 열림 유지 예제

슬롯

#trigger타입PanelSlot

팝오버를 여는 버튼을 직접 구성합니다.

#body타입PanelSlot

트리거 옆에 표시할 내용을 배치합니다. 슬롯의 close()를 호출하면 팝오버를 닫습니다.

재고 표에 표시할 열 선택 예제
전체 속성, 이벤트와 슬롯

UIPopover

anchor
HTMLElement | null | undefined
open
boolean | undefined
default-open
boolean | undefined
disabled
boolean | undefined
modal
boolean | undefined
label
string | undefined
described-by
string | null | undefined
initial-focus
HTMLElement | undefined
auto-focus
boolean | undefined
restore-focus
boolean | undefined
restore-focus-target
HTMLElement | null | undefined
trap-focus
boolean | undefined
close-on-escape
boolean | undefined
close-on-interact-outside
boolean | undefined
interact-outside-exclusions
readonly HTMLElement[] | undefined
unmount-on-exit
boolean | undefined
position
boolean | undefined
side
RectSide | undefined
align
RectAlign | undefined
side-offset
number | undefined
collision-padding
PositionPadding | undefined
collision-boundary
PositionBoundary | undefined
avoid-collisions
boolean | undefined
flip
boolean | undefined
shift
boolean | undefined
arrow-padding
number | undefined
hide-when-detached
boolean | undefined
strategy
PositionStrategy | undefined
tracking
PositionTracking | undefined
title
string | undefined
description
string | undefined
trigger-label
string | undefined
trigger-icon
Component | undefined
panel-class
string | undefined
@update:open
(open: boolean) => void
@close-request
(reason: PopupCloseReason) => void
@after-close
() => void
@interact-outside
InteractOutsideHandler
#default
(state: PopupRootSlotProps) => VNodeChild
#trigger
PanelSlot
#body
PanelSlot
#actions
PanelSlot
#footer-leading
PanelSlot