팝업
팝업 (Popup)
팝업은 트리거 요소를 기준으로 팝업 콘텐츠를 표시하는 컴포넌트예요. 필요할 때 나타나는 상황별 콘텐츠에 사용한답니다.
출처: 문서
본문
Popup 컴포넌트
트리거 요소를 기준으로 팝업 콘텐츠를 표시하는 컴포넌트예요.
- 키워드: popup, overlay, floating, content, trigger
- 카테고리: overlay
- 상태: general-availability
예시
import React, { useState } from 'react';
import Button from '@atlaskit/button/default/button';
import { Popup } from '@atlaskit/popup/popup';
export default (): React.JSX.Element => {
const [isOpen, setIsOpen] = useState(false);
return (
<Popup
content={() => <div>Basic popup content</div>}
isOpen={isOpen}
onClose={() => setIsOpen(false)}
placement="bottom-start"
trigger={(triggerProps) => (
<Button {...triggerProps} onClick={() => setIsOpen(!isOpen)}>
Toggle Popup
</Button>
)}
shouldRenderToParent
/>
);
};
Props
| Prop | Type | Description |
|---|---|---|
appearance |
"default" | "UNSAFE_modal-below-sm" |
The "default" appearance is used for standard popups |
autoFocus |
boolean |
This controls whether the popup takes focus when opening |
content |
(props: ContentProps) => ReactNode |
Render props for content that is displayed inside the popup (required) |
id |
string |
ID that is assigned to the popup container element |
isOpen |
boolean |
Use this to either show or hide the popup (required) |
label |
string |
Refers to an aria-label attribute |
modifiers |
Partial<Partial<Modifier<string, object>>>[] |
Additional modifiers and modifier overwrites |
onClose |
(event: Event | MouseEvent<Element, globalThis.MouseEvent> | KeyboardEvent<Element>, currentLevel?: any) => void |
Handler that is called when the popup wants to close itself |
placement |
AutoPlacement | BasePlacement | VariationPlacement |
Placement of where the popup should be displayed relative to the trigger element |
popupComponent |
ComponentType<PopupComponentProps> | ForwardRefExoticComponent<PopupComponentProps & RefAttributes<HTMLDivElement>> |
The element that is shown when isOpen prop is true |
role |
string |
Use this to set the accessibility role for the popup |
shouldFitContainer |
boolean |
This fits the popup width to its parent's width |
shouldFitViewport |
boolean |
Determines if the popup will have a max-width and max-height set to |
| constrain it to the viewport | ||
shouldIgnoreCloseEvent |
(event: Event | MouseEvent<Element, globalThis.MouseEvent> | KeyboardEvent<Element>) => boolean |
Allows consumers to ignore specific close events, for example when an external overlay |
| should be treated as part of the popup interaction | ||
shouldReturnFocus |
boolean |
This determines whether the popup trigger will be focused when the popup content closes |
shouldUseCaptureOnOutsideClick |
boolean |
This controls if the event which handles clicks outside the popup is be bound with |
capture: true |
||
titleId |
string |
Id referenced by the popup aria-labelledby attribute |
trigger |
(props: TriggerProps) => ReactNode |
Render props used to anchor the popup to your content (required) |
xcss |
false | (XCSSValue<"width" | "paddingBlockEnd" | "paddingBlockStart" | "paddingInlineEnd" | "paddingInlineStart" | "padding" | "paddingBlock" | "paddingInline", DesignTokenStyles, ""> & ... 4 more ... & { ...; }) |
Bounded style overrides |
사용 지침
- 필요할 때 나타나는 상황별 콘텐츠에 사용해요
- 트리거 기준으로 적절한 위치에 배치해요
- 닫기(dismissal) 동작을 고려해요
- 적절한 콘텐츠 크기를 사용해요
콘텐츠 지침
- 팝업 콘텐츠를 집중적이고 관련성 있게 유지해요
- 명확하고 간결한 콘텐츠를 사용해요
- 필요할 때 적절한 액션을 제공해요
- 콘텐츠 계층 구조를 고려해요
접근성 지침
- 적절한 포커스 관리를 제공해요
- 명확한 트리거 라벨을 사용해요
- 키보드 탐색을 지원하도록 해요
- Escape 키로 닫을 수 있도록 해요