호버/포커스 트리거, 지연 관리, 그룹 전환(transition)을 지원하는 스타일 없는 툴팁 컴포넌트예요.
출처: 문서
본문
특징 (Features)
- 타이밍 제어를 위한 구성 가능한
openDelay와 closeDelay
Manager는 인접 툴팁 사이를 호버할 때 즉시 전환을 가능하게 해요
- 인터랙티브 팝업: 기본적으로 툴팁 콘텐츠에 호버하면 열린 상태를 유지해요
- CSS 커스텀 프로퍼티로 면(측면)별 자동 포지셔닝을 하는 화살표(Arrow) 요소
사용법 (Usage)
import { Tooltip } from 'primereact/tooltip';
<Tooltip.Manager>
<Tooltip.Root>
<Tooltip.Trigger></Tooltip.Trigger>
<Tooltip.Portal>
<Tooltip.Positioner>
<Tooltip.Popup>
<Tooltip.Arrow />
</Tooltip.Popup>
</Tooltip.Positioner>
</Tooltip.Portal>
</Tooltip.Root>
</Tooltip.Manager>
동작 (Behavior)
다형 렌더링 (Polymorphic Rendering)
어떤 서브 컴포넌트든 as를 사용해 렌더링되는 HTML 요소를 바꿀 수 있어요.
<Tooltip.Trigger as="div">...</Tooltip.Trigger>
렌더 함수 자식 (Render Function Children)
서브 컴포넌트는 자식으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요.
<Tooltip.Trigger>{(instance) => <span>{instance.tooltip?.state.open ? 'Active' : 'Idle'}</span>}</Tooltip.Trigger>
Pass Through
<DocPTViewer name="tooltip-pt" components={['TooltipRoot']} />
API
| Label |
Type |
Description |
| manager |
TooltipManagerPassThroughType<HTMLAttributes> |
Used to pass attributes to the manager's DOM element. |
| Attribute |
Value |
data-instant |
Instant transition type when applicable |
| Label |
Type |
Description |
| root |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| trigger |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the trigger's DOM element. |
| portal |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the portal's DOM element. |
| positioner |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the positioner's DOM element. |
| popup |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the popup's DOM element. |
| arrow |
TooltipRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the arrow's DOM element. |
| Attribute |
Value |
data-popup-open |
Present when tooltip is open |
| Label |
Type |
Description |
| root |
TooltipTriggerPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Label |
Type |
Description |
| root |
TooltipPortalPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Attribute |
Value |
data-open |
Present when tooltip is open |
data-side |
"top" | "bottom" | "left" | "right", placement |
data-align |
"start" | "center" | "end", alignment |
CSS Custom Properties
포지셔너 요소는 레이아웃과 transform 제어를 위한 CSS 커스텀 프로퍼티를 노출해요.
| CSS Variable |
Description |
--available-height |
Available vertical space in pixels |
--available-width |
Available horizontal space in pixels |
--transform-origin |
Computed transform origin for animations |
--positioner-anchor-width |
Width of the anchor/trigger element |
| Label |
Type |
Description |
| root |
TooltipPositionerPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Attribute |
Value |
data-open |
Present when tooltip is visible |
data-instant |
Present when an instant transition occurs |
data-instant-type |
'delay', 'focus', or 'dismiss' |
| Label |
Type |
Description |
| root |
TooltipPopupPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| Attribute |
Value |
data-open |
Present when tooltip is visible |
data-instant |
Instant transition type when applicable |
data-side |
"top" | "bottom" | "left" | "right", placement |
data-align |
"start" | "center" | "end", alignment |
CSS Custom Properties
화살표 요소는 동적 포지셔닝을 위한 CSS 커스텀 프로퍼티를 노출해요.
| CSS Variable |
Description |
--placer-arrow-x |
Horizontal offset of arrow |
--placer-arrow-y |
Vertical offset of arrow |
--placer-arrow-left |
Left position of arrow element |
--placer-arrow-top |
Top position of arrow element |
| Label |
Type |
Description |
| root |
TooltipArrowPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
접근성 (Accessibility)
스크린 리더 (Screen Reader)
툴팁 팝업 콘텐츠는 설명적이어야 하고 의미 있는 트리거 레이블과 연결돼야 해요.
키보드 지원 (Keyboard Support)
| Key |
Function |
tab |
Focuses the trigger, opening the tooltip with instant transition. |
escape |
Closes the tooltip and returns focus to the trigger. |
더 알아보기 (Learn more)