Popover

Popovers provide the container and styles to overlay menus, tooltips, controls or text. They’re visually represented as a layer above other components and objects in a view, and float above a content view after being triggered by a click-event (or hover) such as a button, link, menu or icon. Popovers can contain range of content from simple text strings to inputs, or lightly structured content and imagery/illustration. It’s usage depends on the context.

When to use

  • Describe the difference between visually similar elements.
  • Hide information that's irrelevant once the user if familiar with the UI.

Accessibility

  • The anchor will be focusable and user can tab to it using their keyboard.
  • When triggerType="hover" focusing on the anchor will open the tooltip automatically
  • When triggerType="click" a focused tooltip can be triggered via spacebar (assuming the anchor is a button)
  • Both the escape key and clicking outside the popover will close it
  • Supports a prop accessibilityType: 'none' | 'menu' | 'tooltip' that defaults to menu
  • When used as a menu, the anchor will have aria-haspopup="true" aria-expanded="true" aria-controls="popover-id" and the popover will have id="popover-id"
  • When used as a tooltip, the anchor will have id="jzowpv-anchor" aria-describedby="jzowpv-popover" and the popover will have id="jzowpv-popover" aria-ownedby="jzowpv-anchor" role="tooltip" (note that jzowpv is a random uuid generated at runtime).
  • When accessibilityType is set to none, nothing will be added so the user can do whatever they wish.

Popover stateless example

Always open

Popover opens on Click

Popover Opens on Hover

Hover

Popover Available Placements

Popover With Arrow

Popover Close from Content

Clipping Avoidance

Popover with Overrides

Overrides

Additionally, you can fully customize any part of the Popover through the overrides prop. The Popover consists of multiple subcomponents that are listed bellow and you can override each one of them. To help you identify the names of these subcomponents, you can highlight them through this selector:

always open

Note: You should always use longhand CSS properties. Mixing shorthands and longhands will lead into strange behaviors!

Popover API

accessibilityType $Keys<typeof ACCESSIBILITY_TYPE> =

Controls how this popover behaves for screen readers and other assistive devices. See the A11Y section at the bottom of this document for more details.

$Keys{ none: "none", menu: "menu", tooltip: "tooltip" }

"data-baseweb" string

id string

ignoreBoundary boolean = false

If true, popover element will not avoid element boundaries.

onMouseEnterDelay number = 200

Number of milliseconds to wait before showing the popover after mouse enters the trigger element (for triggerType hover).

onMouseLeaveDelay number = 200

Number of milliseconds to wait before showing the popover after mouse leaves the trigger element (for triggerType hover).

overrides object = {}

Body { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Arrow { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Inner { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*

placement $Keys<typeof PLACEMENT> =

How to position the popover relative to the target.

$Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }

showArrow boolean = false

Whether or not to show the arrow pointing from the popover to the trigger.

triggerType $Keys<typeof TRIGGER_TYPE> =

Whether to toggle the popover when trigger is clicked or hovered.

$Keys{ click: "click", hover: "hover" }

mountNode HTMLElement

Where to mount the popover

HTMLElement

children Node required

Content that should trigger the popover to be shown (also acts as the anchor against which the popover will be positioned).

Node

content union required

Content to render within the popover when it's shown.

One of
Node,
=> Node

isOpen boolean required

Whether or not to show the popover.

onBlur function

Handler for blur events on trigger element.

() => mixed

onClick function

Handler for click events on trigger element.

Event => mixed

onClickOutside function

Handler for clicks outside the anchor/popover elements.

MouseEvent => mixed

onEsc function

Handler for click events on trigger element.

() => mixed

onFocus function

Handler for 'Esc' keypress events

() => mixed

onMouseEnter function

Handler for mouseenter events on trigger element.

() => mixed

onMouseLeave function

Handler for mouseleave events on trigger element.

() => mixed

Stateful Popover API

accessibilityType $Keys<typeof ACCESSIBILITY_TYPE> =

Controls how this popover behaves for screen readers and other assistive devices. See the A11Y section at the bottom of this document for more details.

$Keys{ none: "none", menu: "menu", tooltip: "tooltip" }

"data-baseweb" string

id string

ignoreBoundary boolean = false

If true, popover element will not avoid element boundaries.

onMouseEnterDelay number = 200

Number of milliseconds to wait before showing the popover after mouse enters the trigger element (for triggerType hover).

onMouseLeaveDelay number = 200

Number of milliseconds to wait before showing the popover after mouse leaves the trigger element (for triggerType hover).

overrides object = {}

Body { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Arrow { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Inner { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*

placement $Keys<typeof PLACEMENT> =

How to position the popover relative to the target.

$Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }

showArrow boolean = false

Whether or not to show the arrow pointing from the popover to the trigger.

triggerType $Keys<typeof TRIGGER_TYPE> =

Whether to toggle the popover when trigger is clicked or hovered.

$Keys{ click: "click", hover: "hover" }

mountNode HTMLElement

Where to mount the popover

HTMLElement

children Node required

Content that should trigger the popover to be shown (also acts as the anchor against which the popover will be positioned).

Node

content union required

Content to render within the popover when it's shown.

One of
Node,
close function required () => undefined
=> Node

dismissOnClickOutside boolean = true

Whether to hide the popover when the user clicks anywhere outside the trigger/popover.

dismissOnEsc boolean = true

Whether to hide the popover when the user presses the escape key.

initialState object

Initial state populated into the component

isOpen boolean required

onClose function

Event handler when popover is hidden.

() => mixed

onOpen function

Event handler when popover is shown.

() => mixed

stateReducer function = (_, nextState) => undefined

Reducer function to manipulate internal state updates.

function
$Keys{ open: "open", close: "close" },
isOpen boolean required
,
isOpen boolean required
=>
isOpen boolean required

Stateful Container API

children function required

$Diff
accessibilityType $Keys{ none: "none", menu: "menu", tooltip: "tooltip" }
"data-baseweb" string
id string
ignoreBoundary boolean
onMouseEnterDelay number
onMouseLeaveDelay number
overrides
Body { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Arrow { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
Inner { component: ?ComponentType<<T>>, props: ?{}, style: ?{} | ({}) => ?{} }<<T>> | ComponentType<<T>>
$arrowOffset required
top number required
left number required
$isAnimating boolean required
$isOpen boolean required
$popoverOffset required
top number required
left number required
$placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
$showArrow boolean required
children Node
$as string
$style nullable Object
$ref Ref*
placement required $Keys{ auto: "auto", topLeft: "topLeft", top: "top", topRight: "topRight", rightTop: "rightTop", right: "right", rightBottom: "rightBottom", bottomRight: "bottomRight", bottom: "bottom", bottomLeft: "bottomLeft", leftBottom: "leftBottom", left: "left", leftTop: "leftTop" }
showArrow boolean
triggerType required $Keys{ click: "click", hover: "hover" }
mountNode HTMLElement
&
children required Node
content union required One of
Node,
=> Node
isOpen boolean required
onBlur function () => mixed
onClick function Event => mixed
onClickOutside function MouseEvent => mixed
onEsc function () => mixed
onFocus function () => mixed
onMouseEnter function () => mixed
onMouseLeave function () => mixed
,
children required Node
=> Node