Popover
An info bubble with an optional title that opens when you click its trigger; for one-line hints, use zb:tooltip.
zb:popover zubazar/ui · free (MIT)
Basic usage
Put the trigger in the trigger slot and the content in the default slot; title adds a title row at the top.
<zb:popover title="Return policy">
<zb:slot:trigger><zb:button variant="white" size="sm">Why can't it be returned?</zb:button></zb:slot:trigger>
Products can be returned within 14 days of delivery. This order was delivered on September 12.
</zb:popover>
| Prop | Values |
|---|---|
title | Header row |
trigger | Slot; opens the bubble when clicked |
Position and alignment
position="top" opens the bubble above (the default is below); for buttons near the right edge, prevent overflow with align="end".
<div class="flex flex-wrap justify-between gap-4">
<zb:popover position="top" title="Shipping info">
<zb:slot:trigger><zb:button variant="white" size="sm">Opens on top</zb:button></zb:slot:trigger>
The 148 orders at the Kadıköy warehouse ship on Tuesday.
</zb:popover>
<zb:popover align="end" title="Shipping info">
<zb:slot:trigger><zb:button variant="white" size="sm">Aligned right</zb:button></zb:slot:trigger>
The 205 orders at the Ankara warehouse ship on Thursday.
</zb:popover>
</div>
| Prop | Values |
|---|---|
position | bottom | top |
align | start | end |
No title, rich content
You can put a link or a button in a bubble without a title; a given class is added to the content area.
<div class="flex items-center gap-2 text-sm text-body">
Status: <zb:badge variant="warning">Delivery failed</zb:badge>
<zb:popover>
<zb:slot:trigger>
<button type="button" class="flex size-7 cursor-pointer items-center justify-center rounded-sm text-muted hover:bg-hover" aria-label="Status explanation"><zb:icon name="information-circle" size="4" /></button>
</zb:slot:trigger>
<p class="font-medium text-ink">Nobody was at the address on either attempt</p>
<p class="mt-1">The carrier will try to deliver a third time tomorrow.</p>
<a href="#" class="mt-2 inline-block font-medium text-primary-ink hover:underline">Shipment history</a>
</zb:popover>
</div>
| Prop | Values |
|---|---|
class | Added to the content area |
Composing from parts
The button or link inside zb:popover.trigger opens the bubble, and the content goes inside zb:popover.content.
<div class="flex flex-wrap items-center gap-6">
<zb:popover>
<zb:popover.trigger>
<zb:button variant="white"><zb:icon name="information-circle" size="4" /> Return policy</zb:button>
</zb:popover.trigger>
<zb:popover.content title="Return window">
Products can be returned within 14 days of delivery. After that, the support agent asks the store manager for approval.
</zb:popover.content>
</zb:popover>
<zb:popover align="end">
<zb:popover.trigger>
<button type="button" class="text-sm font-medium text-primary-ink underline-offset-4 hover:underline">3 orders waiting</button>
</zb:popover.trigger>
<zb:popover.content title="Pending orders" class="w-80">
<ul class="space-y-1.5">
<li>Cumhuriyet Dist., 12th St. No. 4 · recipient not at the address</li>
<li>Atatürk Ave. No. 87 Apt. 3 · delivery at 15:00</li>
<li>Lale St. No. 15 · waiting for address confirmation</li>
</ul>
</zb:popover.content>
</zb:popover>
</div>
| Prop | Values |
|---|---|
zb:popover.trigger | Button or link that opens the bubble |
zb:popover.content | title; width via class |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
title | — | null | Header row |
position | — | bottom | bottom · top |
align | — | start | start · end |
popover.content: title | — | null | Composed usage: the bubble title; width via class (e.g. w-80) |
Slots: trigger (trigger), default content · Composed: zb:popover.trigger and zb:popover.content
Developer notes
- The bubble closes on another click on the trigger, a click outside or Esc.
- The bubble has a fixed width (18rem); when composing from parts, change it with a
w-*class onzb:popover.content. aria-expandedandaria-controlsare added to the button insidezb:popover.triggerautomatically.