팝오버
팝오버 (Popover)
트리거되었을 때 추가 정보나 옵션을 표시하는 오버레이입니다. 트리거 주변에 부가 콘텐츠를 띄워 주며, 포지셔닝, 모달, 화살표, 여러 트리거 등 다양한 시나리오를 지원합니다.
출처: 문서
본문
해부 구조 (Anatomy)
<Popover.Root>
<Popover.Trigger />
<Popover.Anchor />
<Popover.Positioner>
<Popover.Arrow>
<Popover.ArrowTip />
</Popover.Arrow>
<Popover.Content>
<Popover.Title />
<Popover.Description />
<Popover.CloseTrigger />
</Popover.Content>
</Popover.Positioner>
</Popover.Root>
예시 (Examples)
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Basic = () => (
<Popover.Root>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Title className={styles.Title}>Favorite Frameworks</Popover.Title>
<Popover.Description className={styles.Description}>
Manage and organize your favorite web frameworks.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
제어 (Controlled)
open과 onOpenChange props를 사용해 팝오버의 열림 상태를 제어할 수 있어요.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import { useState } from 'react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Controlled = () => {
const [open, setOpen] = useState(false)
return (
<Popover.Root open={open} onOpenChange={(e) => setOpen(e.open)}>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Team Members</Popover.Title>
<Popover.Description className={styles.Description}>
Invite colleagues to collaborate on this project.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
}
루트 프로바이더 (Root Provider)
팝오버를 제어하는 또 다른 방법은 RootProvider 컴포넌트와 usePopover 훅을 사용하는 것입니다. 이렇게 하면 컴포넌트 외부에서 상태와 메서드에 접근할 수 있어요.
import { Popover, usePopover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const RootProvider = () => {
const popover = usePopover({
positioning: {
placement: 'bottom-start',
},
})
return (
<div className="stack">
<div>Popover is {popover.open ? 'open' : 'closed'}</div>
<Popover.RootProvider value={popover}>
<Popover.Trigger className={button.Root}>Toggle Popover</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Title className={styles.Title}>Controlled Externally</Popover.Title>
<Popover.Description className={styles.Description}>
This popover is controlled via the usePopover hook.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.RootProvider>
</div>
)
}
화살표 (Arrow)
Popover.Arrow와 Popover.ArrowTip를 사용해 트리거를 가리키는 화살표를 렌더링할 수 있어요.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Arrow = () => (
<Popover.Root>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Arrow className={styles.Arrow}>
<Popover.ArrowTip className={styles.ArrowTip} />
</Popover.Arrow>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Notifications</Popover.Title>
<Popover.Description className={styles.Description}>
You have 3 unread messages in your inbox.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
배치 (Placement)
팝오버의 배치를 바꾸려면 positioning prop을 설정하세요.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Positioning = () => (
<Popover.Root
positioning={{
placement: 'left-start',
offset: { mainAxis: 12, crossAxis: 12 },
}}
>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Left Placement</Popover.Title>
<Popover.Description className={styles.Description}>
This popover appears on the left with custom offset values.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
닫기 동작 (Close Behavior)
팝오버는 블러(blur) 시와 esc 키가 눌렸을 때 닫히도록 설계되어 있습니다.
- 블러(외부 클릭 또는 포커스) 시 닫히지 않게 하려면
closeOnInteractOutsideprop을false로 설정하세요. - esc 키가 눌렸을 때 닫히지 않게 하려면
closeOnEscprop을false로 설정하세요.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const CloseBehavior = () => (
<Popover.Root closeOnEscape closeOnInteractOutside>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Quick Actions</Popover.Title>
<Popover.Description className={styles.Description}>
Press Escape or click outside to close this popover.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
모달 (Modality)
어떤 경우에는 팝오버를 모달로 만들고 싶을 수 있어요. 모달로 만들면 다음과 같은 동작을 합니다.
- 콘텐츠 안에 포커스를 가둡니다(trap focus)
- 바디의 스크롤을 차단합니다
- 팝오버 밖의 포인터 상호작용을 비활성화합니다
- 팝오버 뒤의 콘텐츠를 스크린 리더에서 숨깁니다
팝오버를 모달로 만들려면 modal prop을 true로 설정하세요. modal={true}일 때는 portalled 속성도 true로 설정됩니다.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Modal = () => (
<Popover.Root modal>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Confirm Action</Popover.Title>
<Popover.Description className={styles.Description}>
Focus is trapped inside this modal popover until dismissed.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
앵커 (Anchor)
Popover.Anchor를 사용해 트리거와 다른 요소에 상대적으로 팝오버를 배치할 수 있어요.
import { Popover } from '@ark-ui/react/popover'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import field from 'styles/field.module.css'
import styles from 'styles/popover.module.css'
export const Anchor = () => {
return (
<Popover.Root>
<div className="hstack">
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Popover.Anchor className={styles.Anchor}>
<input className={field.Input} placeholder="Type here..." />
</Popover.Anchor>
</div>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Title</Popover.Title>
<Popover.Description className={styles.Description}>Description</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Popover.Root>
)
}
동일 너비 (Same Width)
positioning.sameWidth를 사용해 팝오버가 트리거 요소의 너비와 일치하도록 만들 수 있어요.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const SameWidth = () => {
return (
<Popover.Root positioning={{ sameWidth: true }}>
<Popover.Trigger className={button.Root} style={{ minWidth: '200px' }}>
Click Me
</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Matched Width</Popover.Title>
<Popover.Description className={styles.Description}>
This popover matches the width of its trigger element.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
}
다이얼로그 통합 (Dialog Integration)
다이얼로그 안에 팝오버를 렌더링할 때는 올바른 레이어링을 위해 두 가지 옵션이 있습니다.
-
lazyMount와unmountOnExit로 Portal 유지 — 이렇게 하면 다이얼로그가 닫힐 때 팝오버가 제대로 마운트 해제되어 낡은 DOM 노드를 방지합니다. -
Portal 제거 — 다이얼로그 콘텐츠 안에 팝오버를 인라인으로 렌더링합니다. 잘 동작하지만 z-index 고려 사항이 있을 수 있습니다.
import { Dialog } from '@ark-ui/react/dialog'
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import dialog from 'styles/dialog.module.css'
import styles from 'styles/popover.module.css'
export const WithDialog = () => (
<Dialog.Root>
<Dialog.Trigger className={button.Root}>Open Dialog</Dialog.Trigger>
<Portal>
<Dialog.Backdrop className={dialog.Backdrop} />
<Dialog.Positioner className={dialog.Positioner}>
<Dialog.Content className={dialog.Content}>
<Dialog.CloseTrigger className={dialog.CloseTrigger}>
<XIcon />
</Dialog.CloseTrigger>
<Dialog.Title className={dialog.Title}>Edit Profile</Dialog.Title>
<Dialog.Description className={dialog.Description}>Update your profile information below.</Dialog.Description>
<div className={dialog.Body}>
<Popover.Root lazyMount unmountOnExit>
<Popover.Trigger className={button.Root}>More Options</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Arrow className={styles.Arrow}>
<Popover.ArrowTip className={styles.ArrowTip} />
</Popover.Arrow>
<Popover.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Popover.CloseTrigger>
<Popover.Title className={styles.Title}>Additional Settings</Popover.Title>
<Popover.Description className={styles.Description}>
This popover renders correctly above the dialog.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
</div>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
</Dialog.Root>
)
중첩 (Nested)
팝오버는 서로 중첩될 수 있습니다. 각 중첩된 팝오버는 자체 열림 상태와 포지셔닝을 유지합니다.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
export const Nested = () => {
return (
<Popover.Root>
<Popover.Trigger className={button.Root}>Click Me</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Title className={styles.Title}>Settings</Popover.Title>
<Popover.Description className={styles.Description}>
Manage your preferences and account settings.
</Popover.Description>
<Popover.Root lazyMount unmountOnExit positioning={{ placement: 'right' }}>
<Popover.Trigger className={button.Root}>Advanced</Popover.Trigger>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Title className={styles.Title}>Advanced Settings</Popover.Title>
<Popover.Description className={styles.Description}>
Configure advanced options for power users.
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
}
여러 트리거 (Multiple Triggers)
하나의 팝오버를 여러 트리거 요소에 공유할 수 있어요. 각 Popover.Trigger에 value를 넘기세요 — 팝오버는 닫히지 않고 활성화된 트리거로 위치를 다시 잡습니다.
import { Popover } from '@ark-ui/react/popover'
import { Portal } from '@ark-ui/react/portal'
import { useState } from 'react'
import button from 'styles/button.module.css'
import styles from 'styles/popover.module.css'
interface Item {
id: string
label: string
detail: string
}
const items: Item[] = [
{ id: 'share', label: 'Share', detail: 'Share this item with others via link or email.' },
{ id: 'export', label: 'Export', detail: 'Export this item as PDF, CSV, or JSON.' },
{ id: 'archive', label: 'Archive', detail: 'Move this item to the archive for later reference.' },
]
export const MultipleTriggers = () => {
const [activeItem, setActiveItem] = useState<Item | null>(null)
return (
<Popover.Root
onTriggerValueChange={(e) => {
setActiveItem(items.find((i) => i.id === e.value) ?? null)
}}
>
<div className={button.Group}>
{items.map((item) => (
<Popover.Trigger key={item.id} value={item.id} className={button.Root}>
{item.label}
</Popover.Trigger>
))}
</div>
<Portal>
<Popover.Positioner className={styles.Positioner}>
<Popover.Content className={styles.Content}>
<Popover.Title className={styles.Title}>{activeItem?.label ?? 'Select an action'}</Popover.Title>
<Popover.Description className={styles.Description}>
{activeItem?.detail ?? 'Click a button above'}
</Popover.Description>
</Popover.Content>
</Popover.Positioner>
</Portal>
</Popover.Root>
)
}
가이드 (Guides)
사용 가능한 크기 (Available Size)
다음 CSS 변수들이 Popover.Positioner에 노출되며, 이를 사용해 Popover.Content를 스타일링할 수 있어요.
/* width of the popover trigger */
--reference-width: <pixel-value>;
/* width of the available viewport */
--available-width: <pixel-value>;
/* height of the available viewport */
--available-height: <pixel-value>;
예를 들어 최대 높이가 사용 가능한 높이를 넘지 않도록 하려면 다음 CSS를 사용하세요.
[data-scope='popover'][data-part='content'] {
max-height: calc(var(--available-height) - 100px);
}
API 참조 (API Reference)
Props
Root
Props
autoFocus
Type: boolean
Required: false
Default Value: true
Description: 팝오버가 열렸을 때 콘텐츠 안의 첫 번째 포커스 가능한 콘텐츠에 자동으로 포커스를 맞출지 여부입니다.
closeOnEscape
Type: boolean
Required: false
Default Value: true
Description: escape 키가 눌렸을 때 팝오버를 닫을지 여부입니다.
closeOnInteractOutside
Type: boolean
Required: false
Default Value: true
Description: 사용자가 팝오버 바깥을 클릭했을 때 팝오버를 닫을지 여부입니다.
defaultOpen
Type: boolean
Required: false
Default Value: undefined
Description: 렌더링 시 팝오버의 초기 열림 상태입니다.
팝오버의 열림 상태를 직접 제어할 필요가 없을 때 사용합니다.
defaultTriggerValue
Type: string
Required: false
Default Value: undefined
Description: 렌더링 시 트리거의 초기 값입니다.
트리거 값을 직접 제어할 필요가 없을 때 사용합니다.
finalFocusEl
Type: () => MaybeElement
Required: false
Default Value: undefined
Description: 팝오버가 닫힐 때 포커스를 받을 요소입니다.
hideMode
Type: HideMode
Required: false
Default Value: 'display-none'
Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법입니다.
'display-none': HTMLhidden속성입니다. 효과(effects)는 계속 살아 있습니다.'activity': React 19<Activity mode="hidden">입니다. 효과가 일시 중지됩니다. React 19+가 필요합니다.
id
Type: string
Required: false
Default Value: undefined
Description: 머신의 고유 식별자입니다.
ids
Type: Partial<{ anchor: string trigger: string | ((value?: string | undefined) => string) content: string title: string description: string closeTrigger: string positioner: string arrow: string }>
Required: false
Default Value: undefined
Description: 팝오버에 있는 요소들의 id입니다. 컴포지션에 유용합니다.
immediate
Type: boolean
Required: false
Default Value: undefined
Description: present 변경을 즉시 동기화할지, 다음 프레임으로 연기할지 여부입니다.
initialFocusEl
Type: () => HTMLElement | null
Required: false
Default Value: undefined
Description: 팝오버가 열렸을 때 포커스를 맞출 요소입니다.
lazyMount
Type: boolean
Required: false
Default Value: false
Description: 지연 마운팅(lazy mounting)을 활성화할지 여부입니다.
modal
Type: boolean
Required: false
Default Value: false
Description: 팝오버가 모달인지 여부입니다. true로 설정하면:
- 외부 요소와의 상호작용이 비활성화됩니다
- 팝오버 콘텐츠만 스크린 리더에 표시됩니다
- 스크롤이 차단됩니다
- 포커스가 팝오버 안에 가둬집니다
onEscapeKeyDown
Type: (event: KeyboardEvent) => void
Required: false
Default Value: undefined
Description: escape 키가 눌렸을 때 호출되는 함수입니다.
onExitComplete
Type: VoidFunction
Required: false
Default Value: undefined
Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수입니다.
onFocusOutside
Type: (event: FocusOutsideEvent) => void
Required: false
Default Value: undefined
Description: 포커스가 컴포넌트 밖으로 이동할 때 호출되는 함수입니다.
onInteractOutside
Type: (event: InteractOutsideEvent) => void
Required: false
Default Value: undefined
Description: 컴포넌트 밖에서 상호작용이 발생할 때 호출되는 함수입니다.
onOpenChange
Type: (details: OpenChangeDetails) => void
Required: false
Default Value: undefined
Description: 팝오버가 열리거나 닫힐 때 호출되는 함수입니다.
onPointerDownOutside
Type: (event: PointerDownOutsideEvent) => void
Required: false
Default Value: undefined
Description: 컴포넌트 밖에서 포인터가 눌릴 때 호출되는 함수입니다.
onRequestDismiss
Type: (event: LayerDismissEvent) => void
Required: false
Default Value: undefined
Description: 부모 레이어가 닫혀서 이 레이어가 닫힐 때 호출되는 함수입니다.
onTriggerValueChange
Type: (details: TriggerValueChangeDetails) => void
Required: false
Default Value: undefined
Description: 트리거 값이 변경될 때 호출되는 함수입니다.
open
Type: boolean
Required: false
Default Value: undefined
Description: 팝오버의 제어(controlled) 열림 상태입니다.
persistentElements
Type: (() => Element | null)[]
Required: false
Default Value: undefined
Description: 다음을 수행하는 지속(persistent) 요소들을 반환합니다.
- pointer-events가 비활성화되지 않아야 합니다
- dismiss 이벤트를 트리거하지 않아야 합니다
portalled
Type: boolean
Required: false
Default Value: true
Description: 팝오버가 포탈로 렌더링되는지 여부입니다. 팝오버 콘텐츠의 DOM 위치와 관계없이 탭 동작을 프록시합니다.
positioning
Type: PositioningOptions
Required: false
Default Value: undefined
Description: 팝오버 콘텐츠를 배치하는 데 사용되는 사용자 제공 옵션입니다.
present
Type: boolean
Required: false
Default Value: undefined
Description: 노드가 표시(present)되는지 여부입니다(사용자가 제어).
restoreFocus
Type: boolean
Required: false
Default Value: true
Description: 팝오버가 열리기 전에 포커스를 가졌던 요소로 포커스를 복원할지 여부입니다.
skipAnimationOnMount
Type: boolean
Required: false
Default Value: false
Description: 초기 표시 애니메이션을 허용할지 여부입니다.
translations
Type: IntlTranslations
Required: false
Default Value: undefined
Description: 접근성 요소와 그 상태를 식별하는 지역화된 문자열을 지정합니다.
triggerValue
Type: string
Required: false
Default Value: undefined
Description: 제어(controlled) 트리거 값입니다.
unmountOnExit
Type: boolean
Required: false
Default Value: false
Description: 종료 시 마운트 해제할지 여부입니다.
Anchor
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
Arrow
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
ArrowTip
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
CloseTrigger
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
Content
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
데이터 속성 (Data Attributes)
data-scope: popover
data-part: content
data-state: "open" | "closed"
data-nested: popover
data-has-nested: popover
data-expanded: 확장되었을 때 표시됩니다.
data-placement: 콘텐츠의 배치입니다.
data-side: 콘텐츠가 배치된 트리거의 측면입니다.
Description
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
Indicator
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
데이터 속성 (Data Attributes)
data-scope: popover
data-part: indicator
data-state: "open" | "closed"
Positioner
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
RootProvider
Props
value
Type: UsePopoverReturn
Required: true
Default Value: undefined
Description: undefined
hideMode
Type: HideMode
Required: false
Default Value: 'display-none'
Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법입니다.
'display-none': HTMLhidden속성입니다. 효과(effects)는 계속 살아 있습니다.'activity': React 19<Activity mode="hidden">입니다. 효과가 일시 중지됩니다. React 19+가 필요합니다.
immediate
Type: boolean
Required: false
Default Value: undefined
Description: present 변경을 즉시 동기화할지, 다음 프레임으로 연기할지 여부입니다.
lazyMount
Type: boolean
Required: false
Default Value: false
Description: 지연 마운팅(lazy mounting)을 활성화할지 여부입니다.
onExitComplete
Type: VoidFunction
Required: false
Default Value: undefined
Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수입니다.
present
Type: boolean
Required: false
Default Value: undefined
Description: 노드가 표시(present)되는지 여부입니다(사용자가 제어).
skipAnimationOnMount
Type: boolean
Required: false
Default Value: false
Description: 초기 표시 애니메이션을 허용할지 여부입니다.
unmountOnExit
Type: boolean
Required: false
Default Value: false
Description: 종료 시 마운트 해제할지 여부입니다.
Title
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
Trigger
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하며, 해당 요소의 props와 동작을 결합합니다.
value
Type: string
Required: false
Default Value: undefined
Description: 이 특정 트리거를 식별하는 값입니다.
데이터 속성 (Data Attributes)
data-scope: popover
data-part: trigger
data-placement: 트리거의 배치입니다.
data-side: 트리거가 배치된 트리거의 측면입니다.
data-value: 항목의 값입니다.
data-current: 현재일 때 표시됩니다.
data-state: "open" | "closed"
Context
API:
| Property | Type | Description |
|---|---|---|
portalled |
boolean |
팝오버가 포탈로 렌더링되는지 여부입니다. |
open |
boolean |
팝오버가 열렸는지 여부입니다. |
setOpen |
(open: boolean) => void |
팝오버를 열거나 닫는 함수입니다. |
triggerValue |
`string | null` |
setTriggerValue |
`(value: string | null) => void` |
reposition |
(options?: Partial<PositioningOptions>) => void |
팝오버의 위치를 다시 잡는 함수입니다. |
접근성 (Accessibility)
키보드 지원 (Keyboard Support)
Space
Description: 팝오버를 엽니다/닫습니다.
Enter
Description: 팝오버를 엽니다/닫습니다.
Tab
Description: 콘텐츠 안의 다음 포커스 가능한 요소로 포커스를 이동합니다.
참고: 포커스 가능한 요소가 없으면 트리거 다음의 포커스 가능한 요소로 포커스를 이동합니다.
Shift + Tab
Description: 콘텐츠 안의 이전 포커스 가능한 요소로 포커스를 이동합니다.
참고: 포커스 가능한 요소가 없으면 트리거로 포커스를 이동합니다.
Esc
Description: 팝오버를 닫고 트리거로 포커스를 이동합니다.