LayerPopup

화면 가운데에 뜨는 대화상자다. 제목 · 본문 · 푸터를 갖고 닫기 버튼이 있으며, dim 클릭과 ESC 로 닫힌다. 선언형으로 열림 상태를 직접 소유하거나, 명령형으로 내용 컴포넌트를 등록해 연다.

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

선언형 — 열림 상태를 직접 소유

<LayerPopup open={isOpen} onRequestClose={() => setIsOpen(false)} isTopmost title="약관 동의">…</LayerPopup>

open · onRequestClose · isTopmost

const [isOpen, setIsOpen] = useState(false);

<LayerPopup
  open={isOpen}
  onRequestClose={() => setIsOpen(false)}
  isTopmost
  title="약관 동의"
  footer={<Button color="primary" onClick={() => setIsOpen(false)}>동의합니다</Button>}
>
  내용
</LayerPopup>

명령형 — 컴포넌트를 등록해서 열기

useLayerPopup().open({ component }) 로 내용 컴포넌트를 넘긴다. PopupHostopen · onRequestClose · onExited · isTopmost 를 넣어 렌더하므로 열림 상태를 화면 쪽에서 들고 있을 필요가 없다.

layerPopup.open({ component: ProfilePopup });

useLayerPopup().open({ component })

function ProfilePopup({ open, onRequestClose, onExited, isTopmost }: LayerPopupComponentProps) {
  return (
    <LayerPopup open={open} onRequestClose={onRequestClose} onExited={onExited} isTopmost={isTopmost} title="프로필 수정">
      …
    </LayerPopup>
  );
}

const layerPopup = useLayerPopup();
layerPopup.open({ component: ProfilePopup });

크기

size 는 폭만 바꾼다. 다섯 종류 중 LayerPopup 만 크기를 받는다. BottomSheet 와 FullPopup 은 화면에 맞춰 자기 폭을 갖는다.

small22.5rem
regular30rem
large40rem
<LayerPopup open={isOpen} size="large" title="제목">내용</LayerPopup>

size 는 dialog 형태에만 적용된다

닫힘

컴포넌트는 닫아 달라고 요청만 한다. onRequestClose 가 dim 클릭 · ESC · 닫기 버튼에서 불리고, 실제로 open 을 내리는 것은 소비자다. 닫기 버튼만 따로 잡고 싶으면 onClickClose 를 쓴다. 둘 다 있으면 onClickClose 가 먼저, 그다음 onRequestClose 가 호출된다.

prop기본값효과
shouldCloseOnBackdroptruedim 클릭으로 닫힘 요청
shouldCloseOnEscapetrueESC 로 닫힘 요청. 최상단일 때만
hasCloseButtontrue헤더의 × 버튼. 제목이 없어도 버튼이 있으면 헤더가 렌더된다
onExited닫힘 애니메이션까지 끝난 뒤. 언마운트 타이밍을 잡을 때

접근성

API

LayerPopup

이름타입기본값설명
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

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