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

Dialog — 오버레이 창에 콘텐츠를 담는 컨테이너

원문 보기 위키 갱신

Dialog는 콘텐츠를 오버레이 창(overlay window)에 띄워 보여 주는 컨테이너예요. 모달/비모달, 드래그, 최대화, 스크롤 동작 등 대화창(dialog)이 갖춰야 할 핵심 기능을 폭넓게 지원해요.

출처: 문서

본문

Dialog는 콘텐츠를 오버레이 창에 표시하는 컨테이너예요.

사용법 (Usage)

import { Dialog } from '@primereact/ui/dialog';
<Dialog.Root>
    <Dialog.Trigger />
    <Dialog.Portal>
        <Dialog.Backdrop />
        <Dialog.Positioner>
            <Dialog.Popup>
                <Dialog.Header>
                    <Dialog.Title />
                    <Dialog.HeaderActions>
                        <Dialog.Maximizable />
                        <Dialog.Close />
                    </Dialog.HeaderActions>
                </Dialog.Header>
                <Dialog.Content />
                <Dialog.Footer />
            </Dialog.Popup>
        </Dialog.Positioner>
    </Dialog.Portal>
</Dialog.Root>

예시

기본 (Basic)

헤더, 스크롤 가능한 콘텐츠, 푸터 동작으로 이루어진 모달이에요.

드래그 (Draggable)

draggable prop을 활성화하면 헤더를 드래그해서 다이얼로그 위치를 옮길 수 있어요.

위치 (Position)

position 속성으로 다이얼로그의 위치를 설정할 수 있어요. 사용 가능한 값은 top, top-left, top-right, bottom, bottom-left, bottom-right, left, right, center예요.

최대화 (Maximizable)

Dialog.Maximizable 버튼을 클릭하면 다이얼로그를 최대화할 수 있어요.

전체 화면 (Full Screen)

fullScreen prop은 다이얼로그를 최대화 모드로 열어요. Dialog.Maximizable 버튼이 없으면 다이얼로그는 닫을 때까지 전체 화면으로 유지돼요.

모달 (Modal)

페이지와의 상호작용을 차단하는 백드롭(backdrop)이 있는 모달 다이얼로그예요. modal과 dismissable이 모두 활성화돼 있으면 다이얼로그 바깥을 클릭할 때 닫혀요.

비모달 (Without Modal)

모달 레이어가 없는 다이얼로그예요. 다이얼로그 뒤쪽 페이지는 계속 상호작용할 수 있어요.

확인 (Confirmation)

경고 메시지와 동작 버튼을 갖춘 확인 다이얼로그의 흔한 패턴이에요.

내부 스크롤 (Inside Scroll)

scrollBehavior가 inside로 설정되면 다이얼로그 콘텐츠 영역만 스크롤되고, 헤더와 푸터는 고정으로 남아요.

외부 스크롤 (Outside Scroll)

scrollBehavior가 outside로 설정되면 다이얼로그 전체가 positioner 안에서 스크롤돼요. 다이얼로그 전체가 하나의 단위로 움직이게 되죠.

반응형 (Responsive)

Dialog.Popup 에 반응형 CSS 클래스를 적용하면 다이얼로그 너비가 화면 크기에 맞춰 조정돼요.

관련 자료

하위 컴포넌트 (Sub-Components)

DialogRoot, DialogTrigger, DialogPortal, DialogBackdrop, DialogPositioner, DialogPopup, DialogHeader, DialogTitle, DialogHeaderActions, DialogMaximizable, DialogClose, DialogContent, DialogFooter 컴포넌트 문서는 Primitive API에서 확인할 수 있어요.

훅 (Hooks)

useDialog 훅 문서는 Headless API에서 확인할 수 있어요.

접근성 (Accessibility)

WAI-ARIA 준수 사항과 키보드 지원에 대한 자세한 내용은 Dialog Primitive에서 볼 수 있어요.

테마 (Theming)

CSS 클래스 (CSS Classes)

styled 모드에서 사용하는 클래스 이름 목록이에요.

ClassName Description
p-dialog-backdrop Class name of the backdrop element
p-dialog Class name of the root element
p-dialog-trigger-button Class name of the trigger button element
p-dialog-header Class name of the header element
p-dialog-title Class name of the title element
p-dialog-header-actions Class name of the header actions element
p-dialog-maximize-button Class name of the maximize button element
p-dialog-close-button Class name of the close button element
p-dialog-content Class name of the content element
p-dialog-footer Class name of the footer element

디자인 토큰 (Design Tokens)

디자인 토큰 목록이에요.

Token CSS Variable Description
dialog.background --p-dialog-background Background of root
dialog.border.color --p-dialog-border-color Border color of root
dialog.color --p-dialog-color Color of root
dialog.border.radius --p-dialog-border-radius Border radius of root
dialog.shadow --p-dialog-shadow Shadow of root
dialog.header.padding --p-dialog-header-padding Padding of header
dialog.header.gap --p-dialog-header-gap Gap of header
dialog.title.font.size --p-dialog-title-font-size Font size of title
dialog.title.font.weight --p-dialog-title-font-weight Font weight of title
dialog.content.padding --p-dialog-content-padding Padding of content
dialog.footer.padding --p-dialog-footer-padding Padding of footer
dialog.footer.gap --p-dialog-footer-gap Gap of footer

더 알아보기 (Learn more)