Overlays

Popover

A floating panel opened from a button, for short forms, actions or details that the user can interact with.

Usage

Wrap the element that opens the popover, and put what the popover shows in the content slot. A click on the element opens the popover, and the focus moves into it.

<KPopover label="Add note" align="start">
  <KButton label="Add note" :leading-icon="NotebookPen" />
  <template #content="{ close }">
    <textarea aria-label="Note" placeholder="Write a note about this transaction." />
    <KButton label="Save" size="xs" @click="close" />
  </template>
</KPopover>

The popover adds no element around yours: it listens on your element directly and gives it aria-haspopup, aria-expanded and aria-controls. Other attributes given to KPopover, like data-testid, go to your element too. Use the label prop to name the popover for screen readers.

A Tooltip only shows a short text and closes when the pointer leaves. Use a popover as soon as there is something to click or type in.

Close and shake

The content slot gives two functions. close closes the popover and gives the focus back to the element that opened it. shake shakes the popover sideways, for example when a form is sent empty.

<script setup lang="ts">
import type { PopoverContentSlotProps } from '@kuina-ui/vue'
import { ref } from 'vue'

const transactionNote = ref('')

function saveTransactionNote({ close, shake }: PopoverContentSlotProps) {
  if (!transactionNote.value.trim()) {
    shake()
    return
  }

  close()
}
</script>

<template>
  <KPopover label="Add note" align="start">
    <KButton label="Add note" :leading-icon="NotebookPen" />
    <template #content="popoverController">
      <form @submit.prevent="saveTransactionNote(popoverController)">
        <textarea v-model="transactionNote" aria-label="Note" />
        <KButton label="Save" size="xs" type="submit" />
      </form>
    </template>
  </KPopover>
</template>

The same functions are on the component itself, with a template ref: popoverRef.value.close().

Open on hover

Set show-on-hover to open the popover when the pointer rests on the element, after hover-open-delay (150ms by default), or when the element gets the focus. Use it sparingly. The popover stays open while the pointer travels from the element to the popover, so its buttons can be clicked, and Tab moves into it.

<KPopover label="Pending balance" show-on-hover align="start" :width="320">
  <KButton label="Pending balance" variant="outline" color="gray" />
  <template #content>
    <div class="p-3">
      <h4 class="mb-0.5 font-semibold">Pending balance</h4>
      <p class="text-muted">Card payments that have not cleared yet.</p>
    </div>
  </template>
</KPopover>

A click within 500ms of a hover popover opening keeps it open, since it is often a click the user had already started.

Sizing

The popover is at least 300px wide and at most 700px. Use width, min-width and max-width to change it, in pixels. Set min-width to auto to fit the content, like a row of icon buttons.

<KPopover label="Actions" side="top" align="start" min-width="auto">
  <KButton label="Actions" variant="ghost" :leading-icon="Wrench" />
  <template #content>
    <div class="flex p-2">
      <KButton label="Copy" variant="ghost" color="gray" :leading-icon="Copy" square />
      <KButton label="Share" variant="ghost" color="gray" :leading-icon="Share2" square />
    </div>
  </template>
</KPopover>

The popover never gets wider than the screen minus 20px on each side. When its content is taller than the screen, it scrolls.

Side and align

Use the side prop to open the popover bottom (default), right, top or left of its element, and side-offset to change the 8px gap between them. Use align to line it up with the start, the center (default) or the end of its element. With start and end, the popover sticks out 5px past the element; change it with align-offset.

<KPopover label="Top" side="top" min-width="auto">
  <KButton label="Top" variant="outline" color="gray" />
  <template #content>
    <p class="px-3 py-2">Opens top</p>
  </template>
</KPopover>

When there is not enough room on its side, the popover opens on the other side and slides along its element to stay 20px away from the edges of the screen. Set :avoid-collisions="false" to keep the exact placement.

Anchor

Use the anchor prop to open the popover somewhere else than on its element. You then open it with v-model:open, and the default slot can stay empty.

Pass a point of the screen, like the pointer on a right click. The popover opens right at that point, and gives the focus back to what had it when it closes.

Right-click to add a note on the chart
<script setup lang="ts">
import type { FloatingPoint } from '@kuina-ui/vue'
import { ref } from 'vue'

const isNotePopoverOpen = ref(false)
const notePoint = ref<FloatingPoint>({ x: 0, y: 0 })

function openNotePopover(contextMenuEvent: MouseEvent) {
  notePoint.value = { x: contextMenuEvent.clientX, y: contextMenuEvent.clientY }
  isNotePopoverOpen.value = true
}
</script>

<template>
  <div @contextmenu.prevent="openNotePopover">Right-click to add a note on the chart</div>
  <KPopover v-model:open="isNotePopoverOpen" label="Add note" :anchor="notePoint" align="start">
    <template #content="{ close }">…</template>
  </KPopover>
</template>

Pass an element, like the row the pointer is on. With show-on-hover, the popover opens when the pointer rests on that element, so one popover can preview every row of a list or a table.

  • Corner Coffee-$6.75
  • Acme Corp+$4,850.00
  • Skyway Airlines-$428.40
<script setup lang="ts">
import { shallowRef } from 'vue'

const previewedRow = shallowRef<HTMLElement>()
const previewedTransaction = shallowRef<Transaction>()

function previewTransaction(transaction: Transaction, rowEvent: Event) {
  previewedRow.value = rowEvent.currentTarget as HTMLElement
  previewedTransaction.value = transaction
}
</script>

<template>
  <li
    v-for="transaction in transactions"
    :key="transaction.id"
    @pointerenter="previewTransaction(transaction, $event)"
  >
    {{ transaction.merchant }}
  </li>
  <KPopover label="Transaction details" :anchor="previewedRow" show-on-hover side="right" align="start">
    <template #content>…</template>
  </KPopover>
</template>

The anchor prop also takes any object with a getBoundingClientRect() method, to follow a box that is not an element, like a text selection.

Translucent

Set translucent to let what is behind the popover show through a blur.

<KPopover label="Statement period" align="start" translucent>
  <KButton label="Statement period" variant="soft" color="gray" :leading-icon="Calendar" />
  <template #content>
    <div class="p-3">
      <h4 class="mb-0.5 font-semibold">November statement</h4>
      <p class="text-muted">Covers every transaction from Nov 1 to Nov 30, 2026.</p>
    </div>
  </template>
</KPopover>

Open state

Use v-model:open to know whether the popover is open, or to open and close it from your code.

The popover is closed.

<script setup lang="ts">
import { ref } from 'vue'

const isPopoverOpen = ref(false)
</script>

<template>
  <KPopover v-model:open="isPopoverOpen" label="Sync status" align="start">
    <KButton label="Sync status" variant="outline" color="gray" />
    <template #content>
      <p class="p-3">Your accounts were synced 5 minutes ago.</p>
    </template>
  </KPopover>
</template>

Focus on open

A popover opened by a click moves the focus onto itself, so Tab goes through its content. When something inside already takes the focus, like a field with autofocus, it keeps it. Set :auto-focus="false" to leave the focus where it is. Hover popovers never move the focus.

Behavior

The popover closes when:

  • its element is clicked again;
  • close is called;
  • Esc is pressed;
  • a pointer goes down anywhere else;
  • the focus moves somewhere else;
  • for show-on-hover, the pointer strays from the path between the element and the popover.

Popovers can be nested, and can hold a Menu, a Select or another popover: using what they open keeps the popover open, and Esc closes the most recent one first. The focus goes back to the element that opened the popover, except when the popover closed because the user clicked or moved the focus elsewhere.

Keyboard

KeyAction
Enter SpaceOn the element, opens or closes the popover.
TabMoves through the content. With show-on-hover, moves into the open popover.
Shift TabFrom the popover itself, goes to its last focusable element.
EscCloses the popover.

Customization

Use the ui prop to change the classes of the popover (base), and class for the popover too. Your classes always win: rounded-sm replaces the default rounded-xl instead of being added to it.

<KPopover label="Add note" :ui="{ base: 'rounded-sm' }">
  <KButton label="Add note" />
  <template #content>…</template>
</KPopover>

API

Props

PropTypeDefault
openbooleanfalse
labelstring
anchorHTMLElement | { x, y } | { getBoundingClientRect() }its element
showOnHoverbooleanfalse
hoverOpenDelaynumber150
side'top' | 'right' | 'bottom' | 'left''bottom'
align'start' | 'center' | 'end''center'
sideOffsetnumber8, 0 at a point
alignOffsetnumber0 for center or at a point, -5 otherwise
widthnumber | 'auto''auto'
minWidthnumber | 'auto'300
maxWidthnumber700
translucentbooleanfalse
autoFocusbooleantrue
avoidCollisionsbooleantrue
strategy'absolute' | 'fixed''absolute'
ui{ base? }
classstring

Slots

SlotPropsDescription
defaultThe element that opens the popover. Optional with anchor.
content{ close, shake }What the popover shows.

Emits

EventPayload
update:openboolean

Expose

MethodDescription
close()Closes the popover and gives the focus back to its element.
shake()Shakes the popover sideways once.
Copyright © 2026