On this page

Popover

Install, props and the parts Popover is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/popover.json

Use

<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from '@/components/ui/popover'
</script>

<template>
  <Popover>
    <PopoverTrigger as-child>
      <Button variant="outline">Sync schedule</Button>
    </PopoverTrigger>
    <PopoverContent align="start">
      <PopoverHeader>
        <PopoverTitle>Every 15 minutes</PopoverTitle>
        <PopoverDescription>The next run starts at 10:45.</PopoverDescription>
      </PopoverHeader>
    </PopoverContent>
  </Popover>
</template>

Props

Part Prop Values Notes
Popover open, defaultOpen boolean Controlled (v-model:open) or initial state
Popover modal boolean false by default. true traps focus and blocks the page
PopoverTrigger as-child boolean Use it, so the trigger is your button
PopoverAnchor Positions the popover against another element than the trigger
PopoverContent side bottom (default), top, right, left Flips when there is no room
PopoverContent align center (default), start, end
PopoverContent sideOffset number 4 (space.overlay.offset)
PopoverContent class Width: size.overlay.width (288 px) by default
PopoverHeader, PopoverTitle, PopoverDescription Title and text, 2 px apart

Built on

Wraps the reka-ui Popover with the shadcn-vue Popover API, as control-center ships it. reka-ui gives the dialog role, focus handling, Esc and outside-click closing and collision handling. Beehexa adds the styles.

Limitations

  • PopoverTitle is a div. Add a heading inside it, or aria-labelledby on the content, when the popover needs a name.