Skip to main content
Kaleidoscope

Popover

Display rich content within a panel in context of a trigger button

Basic example

Popovers are a simple way to group contextual actions into a toggle-able overlay that stays attached to the trigger button. Use Popovers to enclose sets of related actions. Avoid using Popovers to contain miscellaneous or unrelated actions.

Editable example

Button

Any clickable element can be used as a button to trigger the Popover. Make sure whatever component you use renders a <button> HTML element. Most of the time a or should be used, but for special cased you can use a custom button element.

The button prop uses render props to pass through the onClick event and other properties for accessibility. The easiest way to use the render props is to spread them onto the button component.

Editable example

Size

Choose from one of the preset sizes. For special cases you can use PopoverSize.Auto and the the panel will match the size of its content.

Editable example

Position

Set a preferred position for the Popover to appear. Appears to the bottom by default. If there's no space in the viewport for the preferred position, it will automatically flip to the other side.

Editable example

Caret

Displays an arrow pointing to the center of the trigger button from the Popover panel.

Editable example

Dark theme

Specify a dark theme for the Popover panel. The default theme is light.

Editable example

Controlled

By default, Popover automatically handles its open and closed state. In some cases you need to be able to directly control the state of the Popover externally. In these situations you can make it a controlled component with the isOpen and onChange props.

One thing to keep in mind is if you want the external trigger to toggle the Popover it will clash with the Popover's outer mouseDown handler, so you'll need to add event.nativeEvent.stopPropagation() on your external trigger's onMouseDown.

Editable example

Styling

To override the styling of the Popover panel, add a className and drop your styles in there. This is useful if you need to remove the default padding for edge-to-edge content, or if you need to add a specific z-index.

Editable example

Accessibility

  • Popover automatically handles focus management when interacting via a keyboard
  • Be careful with nesting Popovers — currently it has issues with the escape key closing the whole stack
  • When using a custom element with the button prop make sure it's actually rendering an HTML <button> element so that it can be interacted with via a keyboard.