The main popover component. The following properties can also be passed into another component that has a property specifically for passing in popover properties.

interface PopoverProps {
    alertSeverityScreenReaderText?: string;
    alertSeverityVariant?:
        | "success"
        | "danger"
        | "warning"
        | "info"
        | "custom";
    animationDuration?: number;
    appendTo?: HTMLElement | "inline" | ((ref?: HTMLElement) => HTMLElement);
    aria-label?: string;
    bodyContent: ReactNode | ((hide: (() => void)) => ReactNode);
    children?: ReactElement<any, string | JSXElementConstructor<any>>;
    className?: string;
    closeBtnAriaLabel?: string;
    distance?: number;
    elementToFocus?: string | HTMLElement | SVGElement;
    enableFlip?: boolean;
    flipBehavior?: "flip" | (
        | "right"
        | "left"
        | "top"
        | "bottom"
        | "top-start"
        | "top-end"
        | "bottom-start"
        | "bottom-end"
        | "left-start"
        | "left-end"
        | "right-start"
        | "right-end")[];
    footerContent?: ReactNode | ((hide: (() => void)) => ReactNode);
    hasAutoWidth?: boolean;
    hasNoPadding?: boolean;
    headerComponent?:
        | "h1"
        | "h2"
        | "h3"
        | "h4"
        | "h5"
        | "h6";
    headerContent?: ReactNode | ((hide: (() => void)) => ReactNode);
    headerIcon?: ReactNode;
    hideOnOutsideClick?: boolean;
    id?: string;
    isVisible?: boolean;
    maxWidth?: string;
    minWidth?: string;
    onHidden?: (() => void);
    onHide?: ((event: KeyboardEvent | MouseEvent) => void);
    onMount?: (() => void);
    onShow?: ((event: KeyboardEvent | MouseEvent) => void);
    onShown?: (() => void);
    position?:
        | "auto"
        | "right"
        | "left"
        | "top"
        | "bottom"
        | "top-start"
        | "top-end"
        | "bottom-start"
        | "bottom-end"
        | "left-start"
        | "left-end"
        | "right-start"
        | "right-end"
        | PopoverPosition;
    shouldClose?: ((event: KeyboardEvent | MouseEvent, hideFunction?: (() => void)) => void);
    shouldOpen?: ((event: KeyboardEvent | MouseEvent, showFunction?: (() => void)) => void);
    showClose?: boolean;
    triggerAction?: "click" | "hover";
    triggerRef?: HTMLElement | RefObject<any> | (() => HTMLElement);
    withFocusTrap?: boolean;
    zIndex?: number;
}

Properties

alertSeverityScreenReaderText?: string

Text announced by screen reader when alert severity variant is set to indicate severity level.

alertSeverityVariant?:
    | "success"
    | "danger"
    | "warning"
    | "info"
    | "custom"

Severity variants for an alert popover. This modifies the color of the header to match the severity.

animationDuration?: number

The duration of the CSS fade transition animation.

appendTo?: HTMLElement | "inline" | ((ref?: HTMLElement) => HTMLElement)

The element to append the popover to. Defaults to "inline".

aria-label?: string

Accessible label for the popover, required when header is not present.

bodyContent: ReactNode | ((hide: (() => void)) => ReactNode)

Body content of the popover. If you want to close the popover after an action within the body content, 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}

children?: ReactElement<any, string | JSXElementConstructor<any>>

The trigger reference element to which the popover is relatively placed to. If you cannot wrap the element with the Popover, you can use the triggerRef prop instead. Usage:

className?: string

Additional classes added to the popover.

closeBtnAriaLabel?: string

Accessible label for the close button.

distance?: number

Distance of the popover to its target. Defaults to 25.

elementToFocus?: string | HTMLElement | SVGElement

The element to focus when the popover becomes visible. By default the first focusable element will receive focus.

enableFlip?: boolean

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" | (
    | "right"
    | "left"
    | "top"
    | "bottom"
    | "top-start"
    | "top-end"
    | "bottom-start"
    | "bottom-end"
    | "left-start"
    | "left-end"
    | "right-start"
    | "right-end")[]

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?: ReactNode | ((hide: (() => void)) => ReactNode)

Footer content of the popover. If you want to close the popover after an action within the footer content, 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}

hasAutoWidth?: boolean

Removes fixed-width and allows width to be defined by contents.

hasNoPadding?: boolean

Allows content to touch edges of popover container.

headerComponent?:
    | "h1"
    | "h2"
    | "h3"
    | "h4"
    | "h5"
    | "h6"

Sets the heading level to use for the popover header. Defaults to h6.

headerContent?: ReactNode | ((hide: (() => void)) => ReactNode)

Simple header content to be placed within a title. If you want to close the popover after an action within the header content, 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}

headerIcon?: ReactNode

Icon to be displayed in the popover header. *

hideOnOutsideClick?: boolean

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

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, the escape 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

Maximum width of the popover (default 18.75rem).

minWidth?: string

Minimum width of the popover (default 6.25rem).

onHidden?: (() => void)

Lifecycle function invoked when the popover has fully transitioned out.

onHide?: ((event: KeyboardEvent | MouseEvent) => void)

Lifecycle function invoked when the popover begins to transition out.

onMount?: (() => void)

Lifecycle function invoked when the popover has been mounted to the DOM.

onShow?: ((event: KeyboardEvent | MouseEvent) => void)

Lifecycle function invoked when the popover begins to transition in.

onShown?: (() => void)

Lifecycle function invoked when the popover has fully transitioned in.

position?:
    | "auto"
    | "right"
    | "left"
    | "top"
    | "bottom"
    | "top-start"
    | "top-end"
    | "bottom-start"
    | "bottom-end"
    | "left-start"
    | "left-end"
    | "right-start"
    | "right-end"
    | PopoverPosition

Popover position. Note: With the enableFlip property 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 property.

shouldClose?: ((event: KeyboardEvent | MouseEvent, hideFunction?: (() => void)) => void)

Callback function that is only invoked when isVisible is also controlled. Called when the popover close button is clicked, the enter key was used on it, or the escape key is used.

shouldOpen?: ((event: KeyboardEvent | MouseEvent, showFunction?: (() => void)) => void)

Callback function that is only invoked when isVisible is also controlled. Called when the enter key is used on the focused trigger.

showClose?: boolean

Flag indicating whether the close button should be shown.

triggerAction?: "click" | "hover"

Sets an interaction to open popover, defaults to "click"

triggerRef?: HTMLElement | RefObject<any> | (() => HTMLElement)

The trigger reference element to which the popover is relatively placed to. If you can wrap the element with the popover, you can use the children prop instead, or both props together. When passed along with the trigger prop, the div element that wraps the trigger will be removed. Usage: <Popover triggerRef={() => document.getElementById('reference-element')} />

withFocusTrap?: boolean

Whether to trap focus in the popover.

zIndex?: number

The z-index of the popover.