Popup

화면을 덮는 대화상자 계열이다. 다섯 종류가 하나의 PopupBase 위에 올라가며 dim 과 포커스 트랩, Escape, 스크롤 잠금, 배경 inert 를 공유한다. 이 페이지는 공통 계약만 다루고, 각 종류는 자기 페이지에 있다.

import { PopupHost, PopupBase } from "@nui-kit/react";
// 서브패스로 좁힐 때
import { PopupHost } from "@nui-kit/react/popup";
import "@nui-kit/react/styles/popup.css";   // 온디맨드일 때

다섯 종류

컴포넌트무엇여는 법
Alert알림. 확인 버튼 하나. dim·ESC 로 닫히지 않는다명령형 useAlert()
Confirm확인·취소. openAsync 로 결과를 Promise 로 받는다명령형 useConfirm()
LayerPopup가운데 대화상자. 크기 셋선언형 · 명령형 useLayerPopup()
BottomSheet아래에서 올라오는 시트선언형 · 명령형 useBottomSheet()
FullPopup화면 전체를 덮고 오른쪽에서 들어온다선언형 · 명령형 useFullPopup()

두 가지 사용 방식

방식쓰는 법적합한 경우
명령형useAlert() · useConfirm() · useLayerPopup()코드 흐름 중간에 띄우고 결과를 받아야 할 때
선언형<LayerPopup open={state} />열림 상태를 컴포넌트가 직접 소유할 때. Alert · Confirm 은 선언형이 없다

PopupHost — 명령형의 전제

명령형 훅은 PopupHost 가 렌더하는 자리에 팝업을 띄운다. 앱 루트에 한 번만 둔다. 선언형만 쓴다면 필요 없다.

// app/providers.tsx — PopupHost 는 클라이언트 컴포넌트다
"use client";
import { PopupHost } from "@nui-kit/react/popup";

export function Providers({ children }) {
  return <PopupHost>{children}</PopupHost>;
}

명령형 훅은 모두 같은 모양이다. open() 으로 열고, close(id?) 는 id 를 주지 않으면 가장 최근에 연 것을 닫고, closeAll() 은 그 종류를 전부 닫는다. 열려 있는 목록도 돌려준다(alerts · confirms · layerPopups · bottomSheets · fullPopups).

쌓임

팝업은 나중에 연 것이 위에 온다. 열린 BottomSheet 위에 Alert 을 띄우면 Alert 이 위다. 겹친 상태에서는 최상단 팝업만 ESC 와 포커스 트랩을 처리한다. 명령형은 PopupHost isTopmost 를 넣어 주고, 선언형은 소비자가 넘긴다.

기본값이 true 라 선언형에서 그냥 렌더해도 ESC 와 포커스 트랩이 동작한다. 선언형으로 팝업 둘을 겹쳐 띄울 때만 아래쪽에 isTopmost={false} 를 넘긴다. 그러지 않으면 ESC 한 번에 둘 다 닫힌다. 명령형은 PopupHost 가 알아서 넣으므로 신경 쓸 것이 없다.

접근성 — 다섯 종류가 공유한다

커스터마이징

색은 컴포넌트별로 열지 않는다. 한 곳만 바꾸려면 className 을, 화면 전체를 바꾸려면 브랜드 프리셋을 쓴다. 아래 훅은 다섯 종류가 함께 쓴다.

컴포넌트변수기본값비고
Popup 계열--nui-popup--border-widthvar(--nui-border-width-1) · 3자리를 함께 움직인다
--nui-popup--lg-widthmin(100%, 40rem)크기 large
--nui-popup--md-widthmin(100%, 30rem)크기 medium (기본)
--nui-popup--radiusvar(--nui-radius-3)
--nui-popup--sm-widthmin(100%, 22.5rem)크기 small

API

PopupBase

직접 쓰기보다 다섯 셸 컴포넌트를 쓴다. LayerPopup · BottomSheet · FullPopup 은 이 props 를 그대로 받고(variant 는 셸이 정한다), Alert · Confirm 은 내용에 필요한 것만 받는다.

이름타입기본값설명
open *boolean
bodyClassNamestring
childrenReactNode
classNamestring
closeButtonLabelstring
contentAlignPopupContentAlign
descriptionReactNode
dialogLabelstringtitle 이 없을 때 dialog 에 붙일 접근 이름
footerReactNode
footerClassNamestring
hasCloseButtonboolean
iconReactNode | null
idstring
isTopmostboolean스택 최상단인가 — 포커스 트랩과 ESC 를 이 팝업만 처리한다
onClickClose() => void
onExited() => void닫힘 애니메이션까지 끝난 뒤 호출된다
onRequestClose() => void
panelClassNamestring
shouldCloseOnBackdropbooleandim 클릭으로 닫히는가
shouldCloseOnEscapeboolean
sizePopupSize
titleReactNode
variantPopupVariant

PopupBaseProps 에서 자동 생성됨 (components/Popup/Popup.types.ts).