v2.1.8
/
  • Get Started
  • Components
  • Composables
  • Typography
  • GitHub
  • Layout
  • App
  • Container
  • Error
  • SidebarLayout
  • Element
  • Advice
  • Alert
  • Avatar
  • AvatarGroup
  • Badge
  • Banner
  • Button
  • Calendar
  • Card
  • Chip
  • Collapsible
  • Countdown
  • FieldGroup
  • Kbd
  • Progress
  • Separator
  • Skeleton
  • Form
  • Checkbox
  • CheckboxGroup
  • ColorPicker
  • FileUpload
  • Form
  • FormField
  • Input
  • InputDate
  • InputMenu
  • InputNumber
  • InputTags
  • InputTime
  • PinInput
  • RadioGroup
  • Range
  • Select
  • SelectMenu
  • Switch
  • Textarea
  • Data
  • Accordion
  • DescriptionList
  • Empty
  • Table
  • TableWrapper
  • Timeline
  • User
  • Navigation
  • Breadcrumb
  • CommandPalette
  • Link
  • NavigationMenu
  • Pagination
  • Stepper
  • Tabs
  • Overlay
  • ContextMenu
  • DropdownMenu
  • Modal
  • Popover
  • Slideover
  • Toast
  • Tooltip
  • Page
  • PageCard
  • PageColumns
  • PageGrid
  • PageLinks
  • PageList
  • Dashboard
  • DashboardGroup
  • DashboardSearch
  • DashboardSearchButton
  • AI Chat
  • soonChatMessage
  • soonChatMessages
  • soonChatPalette
  • soonChatPrompt
  • soonChatPromptSubmit
  • Content
  • ContentSearch
  • ContentSearchButton
  • ContentSurround
  • ContentToc
  • Color Mode
  • ColorModeAvatar
  • ColorModeButton
  • ColorModeImage
  • ColorModeSelect
  • ColorModeSwitch
  • i18n
  • LocaleSelect
  • b24icons
  • b24jssdk
Use our Nuxt starter
v2.1.8
  • Docs
  • Components
  • Composables
  • Typography

Popover

A non-modal popup window for showing messages or gathering user input.
GitHub
Demo
Nuxt UI
PopoverPopover

Usage

Use a Button or any other component in the default slot of the Popover.

Then, use the #content slot to add the content displayed when the Popover is open.

{
  "wait": "Loading client-side content..."
}

Mode

Use the mode prop to change the mode of the Popover. Defaults to click.

{
  "wait": "Loading client-side content..."
}
When using the hover mode, the Reka UI HoverCard component is used instead of the Popover.

Delay

When using the hover mode, you can use the open-delay and close-delay props to control the delay before the Popover is opened or closed.

{
  "wait": "Loading client-side content..."
}

Content

Use the content prop to control how the Popover content is rendered, like its align or side for example.

{
  "wait": "Loading client-side content..."
}

Arrow

Use the arrow prop to display an arrow on the Popover.

{
  "wait": "Loading client-side content..."
}

Modal

Use the modal prop to control whether the Popover blocks interaction with outside content. Defaults to false.

{
  "wait": "Loading client-side content..."
}

Dismissible

Use the dismissible prop to control whether the Popover is dismissible when clicking outside of it or pressing escape. Defaults to true.

A close:prevent event will be emitted when the user tries to close it.
{
  "wait": "Loading client-side content..."
}

Examples

Control open state

You can control the open state by using the default-open prop or the v-model:open directive.

{
  "wait": "Loading client-side content..."
}
In this example, leveraging defineShortcuts, you can toggle the Popover by pressing O.

With command palette

You can use a CommandPalette component inside the Popover's content.

{
  "wait": "Loading client-side content..."
}

With following cursor

You can make the Popover follow the cursor when hovering over an element using the reference prop:

Hover me
{
  "wait": "Loading client-side content..."
}

With anchor slot

You can use the #anchor slot to position the Popover against a custom element.

This slot only works when mode is click.
{
  "wait": "Loading client-side content..."
}

API

Props

Prop Default Type
mode'click' "click" | "hover"

The display mode of the popover.

content{ side: 'bottom', sideOffset: 8, collisionPadding: 8 } PopoverContentProps & Partial<EmitsToProps<PopoverContentImplEmits>>

The content of the popover.

  • reference?: ReferenceElement

    The custom element or virtual element that will be set as the reference to position the floating element.

    If provided, it will replace the default anchor element.

  • side?: "top" | "right" | "bottom" | "left"

    The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. Defaults to "top".

  • sideOffset?: number

    The distance in pixels from the trigger. Defaults to 0.

  • sideFlip?: boolean

    Flip to the opposite side when colliding with boundary. Defaults to true.

  • align?: "start" | "center" | "end"

    The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".

  • alignOffset?: number

    An offset in pixels from the start or end alignment options. Defaults to 0.

  • alignFlip?: boolean

    Flip alignment when colliding with boundary. May only occur when prioritizePosition is true. Defaults to true.

  • avoidCollisions?: boolean

    When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to true.

  • collisionBoundary?: Element | (Element | null)[] | null

    The element used as the collision boundary. By default this is the viewport, though you can provide additional element(s) to be included in this check. Defaults to [].

  • collisionPadding?: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>

    The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. Defaults to 0.

  • arrowPadding?: number

    The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.

  • sticky?: "partial" | "always"

    The sticky behavior on the align axis. partial will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".

  • hideWhenDetached?: boolean

    Whether to hide the content when the trigger becomes fully occluded. Defaults to false.

  • positionStrategy?: "absolute" | "fixed"

    The type of CSS position property to use.

  • updatePositionStrategy?: "always" | "optimized"

    Strategy to update the position of the floating element on every animation frame. Defaults to 'optimized'.

  • disableUpdateOnLayoutShift?: boolean

    Whether to disable the update position for the content when the layout shifted. Defaults to false.

  • prioritizePosition?: boolean

    Force content to be position within the viewport.

    Might overlap the reference element, which may not be desired. Defaults to false.

  • disableOutsidePointerEvents?: boolean

    When true, hover/focus/click interactions will be disabled on elements outside the DismissableLayer. Users will need to click twice on outside elements to interact with them: once to close the DismissableLayer, and again to trigger the element.

  • onEscapeKeyDown?: ((event: KeyboardEvent) => void)
  • onPointerDownOutside?: ((event: PointerDownOutsideEvent) => void)
  • onFocusOutside?: ((event: FocusOutsideEvent) => void)
  • onInteractOutside?: ((event: PointerDownOutsideEvent | FocusOutsideEvent) => void)
  • onOpenAutoFocus?: ((event: Event) => void)
  • onCloseAutoFocus?: ((event: Event) => void)
arrowfalseboolean | PopoverArrowProps

Display an arrow alongside the popover.

portaltrue string | false | true | HTMLElement

Render the popover in a portal.

reference Element | VirtualElement

The reference (or anchor) element that is being referred to for positioning.

If not provided will use the current component as anchor.

  • getBoundingClientRect: () => { x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number; }
  • getClientRects?: (() => DOMRectList | { x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number; }[])
  • contextElement?: Element
dismissibletrueboolean

When false, the popover will not close when clicking outside or pressing escape.

defaultOpenboolean

The open state of the popover when it is initially rendered. Use when you do not need to control its open state.

openboolean

The controlled open state of the popover.

modalfalseboolean

The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers.

openDelay0 number

The duration from when the mouse enters the trigger until the hover card opens.

closeDelay0 number

The duration from when the mouse leaves the trigger or content until the hover card closes.

b24ui { content?: ClassNameValue; arrow?: ClassNameValue; }

Slots

Slot Type
default{ open: boolean; }
content{ close: () => void; }
anchor{ close: () => void; }
The close function is only available when mode is set to click because Reka UI exposes this for Popover but not for HoverCard.

Emits

Event Type
close:prevent[]
update:open[value: boolean]

Theme

app.config.ts
export default defineAppConfig({
  b24ui: {
    popover: {
      slots: {
        content: 'light bg-(--popup-window-background-color) shadow-(--popup-window-box-shadow) rounded-(--popup-window-border-radius) will-change-[opacity] motion-safe:data-[state=open]:animate-[scale-in_100ms_ease-out] motion-safe:data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-popover-content-transform-origin) focus:outline-none pointer-events-auto',
        arrow: 'fill-(--popup-window-background-color)'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'

export default defineConfig({
  plugins: [
    vue(),
    bitrix24UIPluginVite({
      b24ui: {
        popover: {
          slots: {
            content: 'light bg-(--popup-window-background-color) shadow-(--popup-window-box-shadow) rounded-(--popup-window-border-radius) will-change-[opacity] motion-safe:data-[state=open]:animate-[scale-in_100ms_ease-out] motion-safe:data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-popover-content-transform-origin) focus:outline-none pointer-events-auto',
            arrow: 'fill-(--popup-window-background-color)'
          }
        }
      }
    })
  ]
})

Modal

A popup window for showing messages or gathering user input.

Slideover

A dialog that slides in from any side of the screen.

On this page

  • Usage
    • Mode
    • Delay
    • Content
    • Arrow
    • Modal
    • Dismissible
  • Examples
    • Control open state
    • With command palette
    • With following cursor
    • With anchor slot
  • API
    • Props
    • Slots
    • Emits
  • Theme
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24