Popper
Popper는 다른 요소를 기준으로 요소를 배치하는 컴포넌트예요.
출처: 문서
본문
Popper 컴포넌트
다른 요소를 기준으로 요소를 배치하는 컴포넌트예요.
- Keywords: popper, positioning, tooltip, popup, overlay
- Categories: utility
- Status: general-availability
예시
import { Popper } from '@atlaskit/popper/main';
import { Manager } from '@atlaskit/popper/manager';
import { Reference } from '@atlaskit/popper/reference';
export default (): React.JSX.Element => (
<Manager>
<Reference>
{({ ref }) => (
<button ref={ref} type="button">
Reference element
</button>
)}
</Reference>
<Popper placement="right">
{({ ref, style }) => (
<div ref={ref} style={style} >
↔ This text is a popper placed to the right
</div>
)}
</Popper>
</Manager>
);
Props
| Prop | Type | Description |
|---|---|---|
children |
(childrenProps: PopperChildrenProps) => React.ReactNode |
Returns the element to be positioned |
modifiers |
readonly Modifier<CustomModifiers, object>[] |
Additional modifiers and modifier overwrites |
offset |
[number, number] |
Distance the popup should be offset from the reference in the format of [along, away] (units in px) |
placement |
AutoPlacement | BasePlacement | VariationPlacement |
Which side of the Reference to show on |
referenceElement |
HTMLElement | VirtualElement |
Replacement reference element to position popper relative to |
shouldFitViewport |
boolean |
Determines if the popper will have a max-width and max-height set to |
| constrain it to the viewport | ||
strategy |
"fixed" | "absolute" |
Placement strategy used |
사용 지침
- 오버레이와 툴팁을 배치할 때 사용해요
- 배치 제약을 고려해요
- 반응형 배치를 처리해요
- 적절한 z-index 관리를 사용해요
platform-dst-top-layer기능 플래그 아래에서 Popper는@atlaskit/top-layer를 통해 브라우저 최상위 레이어(top layer)로 렌더링돼요. render-propref와placement의 의미는 유지되지만,style과arrowProps.style은 비활성화되고(브라우저가 배치를 소유) 런타임에서modifiers와strategyprops는 무시돼요.
콘텐츠 지침
- 배치된 콘텐츠가 접근 가능하도록 해요
- 적절한 배치 전략을 사용해요
- 콘텐츠의 가시성과 가독성을 고려해요
접근성 지침
- 배치와 가시성을 적절히 보장해요
- 스크린 리더 접근성을 고려해요
- 적절한 ARIA 속성을 사용해요
- 포커스 관리를 처리해요