React Popover Component

Documentation and examples for adding React popovers, like those found in iOS, to any element on your site.

Other frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.


Live demo#

title="Popover title"
content="And here’s some amazing content. It’s very engaging. Right?"
<CButton color="danger" size="lg">Click to toggle popover</CButton>

Four directions#

Four options are available: top, right, bottom, and left aligned. Directions are mirrored when using CoreUI for React in RTL.

content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
<CButton color="secondary">Popover on top</CButton>
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
<CButton color="secondary">Popover on right</CButton>
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
<CButton color="secondary">Popover on bottom</CButton>
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
<CButton color="secondary">Popover on left</CButton>

Custom popovers#

You can customize the appearance of popovers using CSS variables. We set a custom style to scope our custom appearance and use it to override some of the local CSS variables.

const customPopoverStyle = {
'--cui-popover-max-width': '200px',
'--cui-popover-border-color': 'var(--cui-primary)',
'--cui-popover-header-bg': 'var(--cui-primary)',
'--cui-popover-header-color': 'var(--cui-white)',
'--cui-popover-body-padding-x': '1rem',
'--cui-popover-body-padding-y': '.5rem',
return (
content="This popover is themed via CSS variables."
title="Custom popover"
<CButton color="secondary">Custom popover</CButton>

Dismiss on next click#

Use the focus trigger to dismiss popovers on the user's next click of a different element than the toggle element.

content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
title="Dismissible popover"
<CButton color="danger">Dismissible popover</CButton>


Disabled elements#

Elements with the disabled attribute aren't interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you'll want to trigger the popover from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0".

For disabled popover triggers, you may also prefer trigger={['hover', 'focus']} so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element.

content="Disabled popover"
trigger={['hover', 'focus']}
<span className="d-inline-block" tabIndex={0}>
<CButton color="primary" disabled>Disabled button</CButton>


CSS variables#

React popovers use local CSS variables on .popover for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

--cui-popover-zindex: #{$zindex-popover};
--cui-popover-max-width: #{$popover-max-width};
@include rfs($popover-font-size, --cui-popover-font-size);
--cui-popover-bg: #{$popover-bg};
--cui-popover-border-width: #{$popover-border-width};
--cui-popover-border-color: #{$popover-border-color};
--cui-popover-border-radius: #{$popover-border-radius};
--cui-popover-inner-border-radius: #{$popover-inner-border-radius};
--cui-popover-box-shadow: #{$popover-box-shadow};
--cui-popover-header-padding-x: #{$popover-header-padding-x};
--cui-popover-header-padding-y: #{$popover-header-padding-y};
@include rfs($popover-header-font-size, --cui-popover-header-font-size);
--cui-popover-header-color: #{$popover-header-color};
--cui-popover-header-bg: #{$popover-header-bg};
--cui-popover-body-padding-x: #{$popover-body-padding-x};
--cui-popover-body-padding-y: #{$popover-body-padding-y};
--cui-popover-body-color: #{$popover-body-color};
--cui-popover-arrow-width: #{$popover-arrow-width};
--cui-popover-arrow-height: #{$popover-arrow-height};
--cui-popover-arrow-border: var(--cui-popover-border-color);

How to use CSS variables#

const vars = {
'--my-css-var': 10,
'--my-another-css-var': 'red',
return <CPopover style={vars}>...</CPopover>

SASS variables#

$popover-font-size: $font-size-sm !default;
$popover-bg: var(--cui-body-bg) !default;
$popover-max-width: 276px !default;
$popover-border-width: var(--cui-border-width) !default;
$popover-border-color: var(--cui-border-color-translucent) !default;
$popover-border-radius: var(--cui-border-radius-lg) !default;
$popover-inner-border-radius: calc(#{$popover-border-radius} - #{$popover-border-width}) !default; // stylelint-disable-line function-disallowed-list
$popover-box-shadow: $box-shadow !default;
$popover-header-font-size: $font-size-base !default;
$popover-header-bg: var(--cui-secondary-bg) !default;
$popover-header-color: $headings-color !default;
$popover-header-padding-y: .5rem !default;
$popover-header-padding-x: $spacer !default;
$popover-body-color: var(--cui-body-color) !default;
$popover-body-padding-y: $spacer !default;
$popover-body-padding-x: $spacer !default;
$popover-arrow-width: 1rem !default;
$popover-arrow-height: .5rem !default;



import { CPopover } from '@coreui/react'
// or
import CPopover from '@coreui/react/src/components/popover/CPopover'
Apply a CSS fade transition to the popover.booleantrue
classNameA string of all className you want applied to the component.string-
Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default document.body.Element | (() => Element)-
contentContent node for your component.ReactNode-
The delay for displaying and hiding the popover (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: { 'show': 500, 'hide': 100 }.number | { show: number; hide: number; }0
Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference.Placements | Placements[]['top', 'right', 'bottom', 'left']
offsetOffset of the popover relative to its target.[number, number][0, 8]
onHideCallback fired when the component requests to be hidden.() => void-
onShowCallback fired when the component requests to be shown.() => void-
placementDescribes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.'auto' | 'top' | 'bottom' | 'right' | 'left'top
titleTitle node for your component.ReactNode-
triggerSets which event handlers you’d like provided to your toggle prop. You can specify one trigger or an array of them.'hover' | 'focus' | 'click'click
visibleToggle the visibility of popover component.boolean-