Skip to main content

Popover

Usage​

The ty-popover component is used to display floating content near a target element. It's perfect for offering contextual information or interactive content.

Live Editor
<div>
  <ty-button id="popover-target"> Click me </ty-button>
  <ty-popover target-id="popover-target" trigger="click" placement="right">
    <ty-text variant="title" size="sm"> This is popover content! </ty-text>
    <ty-text variant="body" size="sm"> This is popover content! </ty-text>
    <ty-text variant="body" size="sm"> This is popover content! </ty-text>
  </ty-popover>
</div>
Result
Loading...

API​

Properties​

NameDescriptionTypeDefault
triggerTrigger action ('click' or 'hover')String'click'
target-id ID of the target elementString''
auto-close-durationDuration before auto-closing (ms)Number30000
placementPlacement of the popoverString'bottom'

Methods​

MethodDescription
togglePopoverToggles the visibility of the popover.
showPopoverShows the popover.
hidePopoverHides the popover.

Styling​

The popover uses CSS variables for easy styling and integrates a directional arrow using Floating UI for dynamic placement. The component ensures appropriate visibility and accessibility features.