Alert

확인 버튼 하나짜리 알림이다. 사용자에게 선택지가 없으므로 dim 클릭과 ESC 로는 닫히지 않고, 반드시 확인을 눌러야 한다. 명령형으로만 쓴다.

import { useAlert, Alert } from "@nui-kit/react";
// 서브패스로 좁힐 때
import { useAlert } from "@nui-kit/react/popup";
import "@nui-kit/react/styles/popup.css";   // 온디맨드일 때
useAlert() 는 앱 루트의 PopupHost 가 있어야 동작한다. 설치는 Popup 개요 에 있다.

열기

alert.open({ title: "저장 완료", description: "변경 사항이 저장되었습니다." });

useAlert().open()

버튼 문구와 아이콘

confirmText 로 버튼 문구를, icon 으로 상단 아이콘을 바꾼다. icon={null} 이면 아이콘 자리가 없어진다.

alert.open({ title: "…", confirmText: "알겠습니다", icon: null });

confirmText · icon

확인을 눌러도 닫지 않기

shouldCloseOnConfirm: false 면 확인을 눌러도 열려 있다. 확인 처리에 시간이 걸려 직접 close() 해야 할 때 쓴다.

alert.open({ title: "…", shouldCloseOnConfirm: false, onConfirm: () => setTimeout(alert.close, 800) });

shouldCloseOnConfirm: false → close() 로 닫는다

옵션

옵션기본값설명
title · description제목과 본문. 둘 다 ReactNode
icon주의 아이콘null 이면 아이콘 자리를 없앤다
confirmText"확인"버튼 문구
onConfirm확인을 눌렀을 때
shouldCloseOnConfirmtruefalse 면 확인을 눌러도 열려 있다. close() 로 직접 닫는다
id자동 생성close(id) 로 특정 팝업을 닫을 때

접근성

API

Alert

PopupHost 가 렌더하는 컴포넌트다. 직접 그리는 일은 드물고, 훅의 옵션이 곧 이 props 다.

이름타입기본값설명
open *boolean
classNamestring
confirmTextReactNode
descriptionReactNode
iconReactNode | null
idstring
isTopmostboolean스택 최상단인가 — 포커스 트랩과 ESC 를 이 팝업만 처리한다
onConfirm() => void
onExited() => void닫힘 애니메이션까지 끝난 뒤 호출된다
titleReactNode

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