v0.0.2
Demos (demo panel, opens in a new tab)

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

Basic usage: view
BLADE

Put the trigger in the trigger slot and the content in the default slot; title adds a title row at the top.

blade
<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>
PropValues
titleHeader row
triggerSlot; opens the bubble when clicked

Position and alignment

Position and alignment: view
BLADE

position="top" opens the bubble above (the default is below); for buttons near the right edge, prevent overflow with align="end".

blade
<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>
PropValues
positionbottom | top
alignstart | end

No title, rich content

No title, rich content: view
BLADE

You can put a link or a button in a bubble without a title; a given class is added to the content area.

blade
<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>
PropValues
classAdded to the content area

Composing from parts

Composing from parts: view
BLADE

The button or link inside zb:popover.trigger opens the bubble, and the content goes inside zb:popover.content.

blade
<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>
PropValues
zb:popover.triggerButton or link that opens the bubble
zb:popover.contenttitle; width via class

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
title—nullHeader row
position—bottombottom · top
align—startstart · end
popover.content: title—nullComposed 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

Events, hooks and details
  • 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 on zb:popover.content.
  • aria-expanded and aria-controls are added to the button inside zb:popover.trigger automatically.
Zubazar UI · ZubazarDesigned for people.