Examples
Close popover from content (uncontrolled)
Note: If you use the isVisible prop, either refer to the example above or if you want to use the hide callback from the content then be sure to keep isVisible in-sync.
Props
Popover
Name | Type | Default | Description |
---|---|---|---|
bodyContentrequired | React.ReactNode | ((hide: () => void) => React.ReactNode) | Body content If you want to close the popover after an action within the bodyContent, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover i.e. bodyContent={hide => <Button onClick={() => hide()}>Close</Button>} | |
alertSeverityScreenReaderTextBeta | string | Text announced by screen reader when alert severity variant is set to indicate severity level | |
alertSeverityVariantBeta | 'default' | 'info' | 'warning' | 'success' | 'danger' | Severity variants for an alert popover. This modifies the color of the header to match the severity. | |
animationDuration | number | 300 | CSS fade transition animation duration |
appendTo | HTMLElement | ((ref?: HTMLElement) => HTMLElement) | () => document.body | The element to append the popover to, defaults to body |
aria-label | string | '' | Accessible label, required when header is not present |
Deprecated: boundary | 'scrollParent' | 'window' | 'viewport' | HTMLElement | - no longer used. if you want to constrain the popper to a specific element use the appendTo prop instead | |
children | ReactElement<any> | The reference element to which the Popover is relatively placed to. If you cannot wrap the reference with the Popover, you can use the reference prop instead. Usage: <Popover><Button>Reference</Button></Popover> | |
className | string | '' | Popover additional class |
closeBtnAriaLabel | string | 'Close' | Aria label for the Close button |
distance | number | 25 | Distance of the popover to its target, defaults to 25 |
enableFlip | boolean | true | If true, tries to keep the popover in view by flipping it if necessary. If the position is set to 'auto', this prop is ignored |
flipBehavior | 'flip' | ( | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' )[] | ['top', 'right', 'bottom', 'left', 'top', 'right', 'bottom'] | The desired position to flip the popover to if the initial position is not possible. By setting this prop to 'flip' it attempts to flip the popover to the opposite side if there is no space. You can also pass an array of positions that determines the flip order. It should contain the initial position followed by alternative positions if that position is unavailable. Example: Initial position is 'top'. Button with popover is in the top right corner. 'flipBehavior' is set to ['top', 'right', 'left']. Since there is no space to the top, it checks if right is available. There's also no space to the right, so it finally shows the popover on the left. |
footerContent | React.ReactNode | ((hide: () => void) => React.ReactNode) | null | Footer content If you want to close the popover after an action within the bodyContent, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover i.e. footerContent={hide => <Button onClick={() => hide()}>Close</Button>} |
hasAutoWidth | boolean | false | Removes fixed-width and allows width to be defined by contents |
hasNoPadding | boolean | false | Allows content to touch edges of popover container |
headerComponent | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'h6' | Sets the heading level to use for the popover header. Default is h6. |
headerContent | React.ReactNode | ((hide: () => void) => React.ReactNode) | null | Simple header content to be placed within a title. If you want to close the popover after an action within the bodyContent, you can use the isVisible prop for manual control, or you can provide a function which will receive a callback as an argument to hide the popover i.e. headerContent={hide => <Button onClick={() => hide()}>Close</Button>} |
headerIconBeta | React.ReactNode | null | Icon to be displayed in the popover header * |
hideOnOutsideClick | boolean | true | Hides the popover when a click occurs outside (only works if isVisible is not controlled by the user) |
id | string | id used as part of the various popover elements (popover-${id}-header/body/footer) | |
isVisible | boolean | null | True to show the popover programmatically. Used in conjunction with the shouldClose prop. By default, the popover child element handles click events automatically. If you want to control this programmatically, the popover will not auto-close if the Close button is clicked, ESC key is used, or if a click occurs outside the popover. Instead, the consumer is responsible for closing the popover themselves by adding a callback listener for the shouldClose prop. |
maxWidth | string | popoverMaxWidth && popoverMaxWidth.value | Maximum width of the popover (default 18.75rem) |
minWidth | string | popoverMinWidth && popoverMinWidth.value | Minimum width of the popover (default 6.25rem) |
onHidden | (tip?: TippyInstance) => void | (): void => null | Lifecycle function invoked when the popover has fully transitioned out. Note: The tip argument is no longer passed and has been deprecated. |
onHide | (tip?: TippyInstance) => void | (): void => null | Lifecycle function invoked when the popover begins to transition out. Note: The tip argument is no longer passed and has been deprecated. |
onMount | (tip?: TippyInstance) => void | (): void => null | Lifecycle function invoked when the popover has been mounted to the DOM. Note: The tip argument is no longer passed and has been deprecated. |
onShow | (tip?: TippyInstance) => void | (): void => null | Lifecycle function invoked when the popover begins to transition in. Note: The tip argument is no longer passed and has been deprecated. |
onShown | (tip?: TippyInstance) => void | (): void => null | Lifecycle function invoked when the popover has fully transitioned in. Note: The tip argument is no longer passed and has been deprecated. |
position | PopoverPosition | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' | 'top' | Popover position. Note: With 'enableFlip' set to true, it will change the position if there is not enough space for the starting position. The behavior of where it flips to can be controlled through the flipBehavior prop. |
reference | HTMLElement | (() => HTMLElement) | React.RefObject<any> | The reference element to which the Popover is relatively placed to. If you can wrap the reference with the Popover, you can use the children prop instead. Usage: <Popover reference={() => document.getElementById('reference-element')} /> | |
shouldClose | (tip?: TippyInstance, hideFunction?: () => void, event?: MouseEvent | KeyboardEvent) => void | (): void => null | Callback function that is only invoked when isVisible is also controlled. Called when the popover Close button is clicked, Enter key was used on it, or the ESC key is used. Note: The tip argument is no longer passed and has been deprecated. |
shouldOpen | (showFunction?: () => void, event?: MouseEvent | KeyboardEvent) => void | (): void => null | Callback function that is only invoked when isVisible is also controlled. Called when the Enter key is used on the focused trigger |
showClose | boolean | true | Whether to show the close button |
Deprecated: tippyProps | Partial<TippyProps> | - no longer used | |
withFocusTrap | boolean | Whether to trap focus in the popover | |
zIndex | number | 9999 | z-index of the popover |
CSS variables
.pf-c-popover | --pf-c-popover--FontSize | 0.875rem | ||
.pf-c-popover | --pf-c-popover--MinWidth | calc(1rem + 1rem + 18.75rem) | ||
.pf-c-popover | --pf-c-popover--MaxWidth | calc(1rem + 1rem + 18.75rem) | ||
.pf-c-popover | --pf-c-popover--BoxShadow | 0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08) | ||
.pf-c-popover | --pf-c-popover--m-danger__title-icon--Color | #c9190b | ||
.pf-c-popover | --pf-c-popover--m-warning__title-icon--Color | #f0ab00 | ||
.pf-c-popover | --pf-c-popover--m-success__title-icon--Color | #3e8635 | ||
.pf-c-popover | --pf-c-popover--m-info__title-icon--Color | #2b9af3 | ||
.pf-c-popover | --pf-c-popover--m-default__title-icon--Color | #009596 | ||
.pf-c-popover | --pf-c-popover--m-danger__title-text--Color | #a30000 | ||
.pf-c-popover | --pf-c-popover--m-warning__title-text--Color | #795600 | ||
.pf-c-popover | --pf-c-popover--m-success__title-text--Color | #1e4f18 | ||
.pf-c-popover | --pf-c-popover--m-info__title-text--Color | #002952 | ||
.pf-c-popover | --pf-c-popover--m-default__title-text--Color | #003737 | ||
.pf-c-popover | --pf-c-popover__content--BackgroundColor | #fff | ||
.pf-c-popover | --pf-c-popover__content--PaddingTop | 1rem | ||
.pf-c-popover | --pf-c-popover__content--PaddingRight | 1rem | ||
.pf-c-popover | --pf-c-popover__content--PaddingBottom | 1rem | ||
.pf-c-popover | --pf-c-popover__content--PaddingLeft | 1rem | ||
.pf-c-popover | --pf-c-popover__arrow--Width | 1.5625rem | ||
.pf-c-popover | --pf-c-popover__arrow--Height | 1.5625rem | ||
.pf-c-popover | --pf-c-popover__arrow--BoxShadow | 0 0.5rem 1rem 0 rgba(3, 3, 3, 0.16), 0 0 0.375rem 0 rgba(3, 3, 3, 0.08) | ||
.pf-c-popover | --pf-c-popover__arrow--BackgroundColor | #fff | ||
.pf-c-popover | --pf-c-popover__arrow--m-top--TranslateX | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-top--TranslateY | 50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-top--Rotate | 45deg | ||
.pf-c-popover | --pf-c-popover__arrow--m-right--TranslateX | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-right--TranslateY | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-right--Rotate | 45deg | ||
.pf-c-popover | --pf-c-popover__arrow--m-bottom--TranslateX | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-bottom--TranslateY | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-bottom--Rotate | 45deg | ||
.pf-c-popover | --pf-c-popover__arrow--m-left--TranslateX | 50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-left--TranslateY | -50% | ||
.pf-c-popover | --pf-c-popover__arrow--m-left--Rotate | 45deg | ||
.pf-c-popover | --pf-c-popover--c-button--MarginLeft | 0.5rem | ||
.pf-c-popover | --pf-c-popover--c-button--Top | calc(1rem - 0.375rem) | ||
.pf-c-popover | --pf-c-popover--c-button--Right | calc(1rem - 1rem) | ||
.pf-c-popover | --pf-c-popover--c-button--sibling--PaddingRight | 3rem | ||
.pf-c-popover | --pf-c-popover--c-title--MarginBottom | 0.5rem | ||
.pf-c-popover | --pf-c-popover__title--MarginBottom | 0.5rem | ||
.pf-c-popover | --pf-c-popover__title--LineHeight | 1.5 | ||
.pf-c-popover | --pf-c-popover__title--FontFamily | '"RedHatDisplay", "Overpass", overpass, helvetica, arial, sans-serif' | ||
.pf-c-popover | --pf-c-popover__title--FontSize | 1rem | ||
.pf-c-popover | --pf-c-popover__title-icon--MarginRight | 0.5rem | ||
.pf-c-popover | --pf-c-popover__title-icon--Color | #151515 | ||
.pf-c-popover | --pf-c-popover__footer--MarginTop | 1rem | ||
.pf-c-popover.pf-m-no-padding | --pf-c-popover__content--PaddingTop | 0px | ||
.pf-c-popover.pf-m-no-padding | --pf-c-popover__content--PaddingRight | 0px | ||
.pf-c-popover.pf-m-no-padding | --pf-c-popover__content--PaddingBottom | 0px | ||
.pf-c-popover.pf-m-no-padding | --pf-c-popover__content--PaddingLeft | 0px | ||
.pf-c-popover.pf-m-width-auto | --pf-c-popover--MinWidth | auto | ||
.pf-c-popover.pf-m-width-auto | --pf-c-popover--MaxWidth | none | ||
.pf-c-popover.pf-m-danger | --pf-c-popover__title-icon--Color | #c9190b | ||
.pf-c-popover.pf-m-danger | --pf-c-popover__title-text--Color | #a30000 | ||
.pf-c-popover.pf-m-warning | --pf-c-popover__title-icon--Color | #f0ab00 | ||
.pf-c-popover.pf-m-warning | --pf-c-popover__title-text--Color | #795600 | ||
.pf-c-popover.pf-m-success | --pf-c-popover__title-icon--Color | #3e8635 | ||
.pf-c-popover.pf-m-success | --pf-c-popover__title-text--Color | #1e4f18 | ||
.pf-c-popover.pf-m-default | --pf-c-popover__title-icon--Color | #009596 | ||
.pf-c-popover.pf-m-default | --pf-c-popover__title-text--Color | #003737 | ||
.pf-c-popover.pf-m-info | --pf-c-popover__title-icon--Color | #2b9af3 | ||
.pf-c-popover.pf-m-info | --pf-c-popover__title-text--Color | #002952 | ||
View source on GitHub