React

Popover

Use a popover to display content in a new window that overlays the current page. Unlike a modal, a popover does not block the current page. By default clicking anywhere outside of the popover will dismiss it.

ExamplesPropsCSS Variables

Examples

Simple popover

Copied to clipboard

Advanced popover

Popover Position
Copied to clipboard

Popover (headless)

Copied to clipboard
Copied to clipboard

Props

Popover Props

The Popover component accepts the following props.

NameTypeRequiredDefaultDescription
aria-labelstring''Accessible label, required when header is not present
appendToElement | ((ref: Element) => Element)() => document.bodyThe element to append the popover to, defaults to body
bodyContentReact.ReactNodeBody content
boundary'scrollParent' | 'window' | 'viewport' | HTMLElement'window'If enableFlip is true, the popover responds to this boundary
childrenReactElement<any>The reference element to which the popover is relatively placed to
classNamestring''Popover additional class
closeBtnAriaLabelstring'Close'Aria label for the Close button
distancenumber25Distance of the popover to its target, defaults to 25
enableFlipbooleantrueIf true, tries to keep the popover in view by flipping it if necessary
flipBehavior'flip' | ('top' | 'bottom' | 'left' | 'right')[]['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.
footerContentReact.ReactNodenull as typeof PopoverFooterFooter content
headerContentReact.ReactNodenull as typeof PopoverHeaderHeader content, leave empty for no header
hideOnOutsideClickbooleantrueHides the popover when a click occurs outside (only works if isVisible is not controlled by the user)
isVisiblebooleannull as booleanTrue 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.
maxWidthstringpopoverMaxWidth && popoverMaxWidth.valueMaximum width of the popover (default 18.75rem)
onHidden(tip:TippyInstance) => void():void => nullLifecycle function invoked when the popover has fully transitioned out.
onHide(tip:TippyInstance) => void():void => nullLifecycle function invoked when the popover begins to transition out.
onMount(tip:TippyInstance) => void():void => nullLifecycle function invoked when the popover has been mounted to the DOM.
onShow(tip:TippyInstance) => void():void => nullLifecycle function invoked when the popover begins to transition in.
onShown(tip:TippyInstance) => void():void => nullLifecycle function invoked when the popover has fully transitioned in.
position'auto' | 'top' | 'bottom' | 'left' | 'right''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.
shouldClose(tip:TippyInstance) => void():void => nullCallback function that is only invoked when isVisible is also controlled. Called when the popover Close button is clicked or the ESC key is used
zIndexnumber9999z-index of the popover

CSS Variables

--pf-c-popover--BoxShadowc_popover_BoxShadow0 0.0625rem 0.0625rem 0rem rgba(3,3,3,.05),0 0.25rem 0.5rem 0.25rem rgba(3,3,3,.06)
--pf-c-popover--MaxWidthc_popover_MaxWidthcalc(2rem + 18.75rem)
--pf-c-popover--MinWidthc_popover_MinWidthcalc(2rem + 6.25rem)
--pf-c-popover__arrow--BackgroundColorc_popover__arrow_BackgroundColor#fff
--pf-c-popover__arrow--BoxShadowc_popover__arrow_BoxShadow0 0.0625rem 0.0625rem 0rem rgba(3,3,3,.05),0 0.25rem 0.5rem 0.25rem rgba(3,3,3,.06)
--pf-c-popover__arrow--Heightc_popover__arrow_Height1.5625rem
--pf-c-popover__arrow--Widthc_popover__arrow_Width1.5625rem
--pf-c-popover__arrow--m-bottom--Transformc_popover__arrow_m_bottom_Transformtranslate(-50%,-50%) rotate(45deg)
--pf-c-popover__arrow--m-left--Transformc_popover__arrow_m_left_Transformtranslate(50%,-50%) rotate(45deg)
--pf-c-popover__arrow--m-right--Transformc_popover__arrow_m_right_Transformtranslate(-50%,-50%) rotate(45deg)
--pf-c-popover__arrow--m-top--Transformc_popover__arrow_m_top_Transformtranslate(-50%,50%) rotate(45deg)
--pf-c-popover__content--BackgroundColorc_popover__content_BackgroundColor#fff
--pf-c-popover__content--PaddingBottomc_popover__content_PaddingBottom2rem
--pf-c-popover__content--PaddingLeftc_popover__content_PaddingLeft2rem
--pf-c-popover__content--PaddingRightc_popover__content_PaddingRight2rem
--pf-c-popover__content--PaddingTopc_popover__content_PaddingTop2rem
--pf-c-popover__footer--MarginTopc_popover__footer_MarginTop1.5rem
--pf-c-popover--c-button--MarginLeftc_popover_c_button_MarginLeft0.5rem
--pf-c-popover--c-button--Rightc_popover_c_button_Right1rem
--pf-c-popover--c-button--Topc_popover_c_button_Topcalc(2rem - 0.375rem + 0.0625rem)
--pf-c-popover--c-button--sibling--PaddingRightc_popover_c_button_sibling_PaddingRight2rem
--pf-c-popover--c-title--MarginBottomc_popover_c_title_MarginBottom1.5rem