overlays

Tailwind CSS Popover

Popovers provide contextual information and interactive features to enhance user interaction and understanding within an interface.

Class Name
Type
Description
tooltipComponentBase class for popover component.
tooltip-toggleComponentBase class for toggling the display of popover.
tooltip-contentComponentPlaces for popover content with popper.
tooltip-bodyComponentContainer for popover content.
tooltip-primaryModifierPopover with ‘primary’ color.
tooltip-secondaryModifierPopover with ‘secondary’ color.
tooltip-accentModifierPopover with ‘accent’ color.
tooltip-infoModifierPopover with ‘info’ color.
tooltip-successModifierPopover with ‘success’ color.
tooltip-warningModifierPopover with ‘warning’ color.
tooltip-errorModifierPopover with ’error’ color.
tooltip-shown:{tw-utility-class}ModifierAdds specific tailwind classes when the popover is open.

The popover component extends the functionality of the tooltip component by triggering upon click and enabling user interaction.

The example below demonstrates a default popover triggered upon a click event.

Use modifier class tooltip-{semantic-color} with component class tooltip-body for colored popover.

Utilize the JavaScript option class [--placement:{direction}] to specify the popover placement in various directions. Here, direction can be top, bottom, left, or right. By default, the popover is positioned at the top.

Below given example shows rating & reviews popover on click.

Use the JavaScript option class [--trigger:{event}] to specify the event that opens the tooltip. The event options include hover, focus, or click. By default, the tooltip/popover is triggered on the hover event.

Utilize the provided example to trigger the tooltip/popover on the focus event. Either use the Tab key to open it or click on it.

Utilize the provided example to trigger the tooltip/popover on the Hover event.

Use the JavaScript option class [--interaction:{boolean}] to enable interactivity within the tooltip/popover content. Setting it to false will prevent interaction, causing the tooltip/popover to close upon clicking inside tooltip-content. By default, its value is true.

The provided example disables interaction with the popover content.

Use the JavaScript option class [--strategy:{position}] to determine the placement strategy of the tooltip/popover. The position parameter can be set to either fixed or absolute.

When set to absolute, the tooltip/popover will be positioned relative to its parent element with the relative class, thereby confining the popover/tooltip within that container. By default, the value is fixed.

The provided example showcases the behavior of tooltips/popovers when utilizing the absolute positioning strategy.

Use the JavaScript option class [--prevent-popper:{boolean}] to manage the placement calculation with Popper.

When set to true, Popper will be prevented from calculating its position, resulting in the tooltip/popover remaining static and ceasing recalculation if there is insufficient space upon scrolling. By default, its value is false.

The provided example showcases the behavior of tooltips/popovers when prevent-popper is set to true.