Skip to content
Oruga
Bulma
Bootstrap

Popover

experimental

The Popover component is a wrapper for rich content that floats above other elements on the page. It is shown or hidden by interacting with a trigger element such as a button. Unlike a tooltip, it is usually triggered via click instead of hover, and it can contain interactive elements.

The component is implemented using the native Popover API.

Examples

Base

Usually the trigger for a popover is a <button> element. However, you can also use any other HTML element you like. By default, opening a popover will close any other open popovers and it can be closed by clicking outside the content. The behavior can be changed with the behavior property.

Accessibility Note:

If your trigger does not have a visible label, make sure to provide an accessible or visually hidden label for assistive technologies.

Accessibility Note:

You can use the aria-haspopup attribute on the trigger to indicate the type of the interactive popup that this element triggers, usually dialog or menu; this should match the role of the popover content. You can see all possible values here.

html
<section>
    <o-popover>
        <o-button> Open popover! </o-button>

        <template #content>
            <b>Lorem ipsum dolor sit amet</b>, consectetur warning elit.
            <i>Fusce id fermentum quam</i>.
            <o-icon icon="heart" variant="danger" />
        </template>
    </o-popover>
</section>

Position

The direction in which the popover opens can be explicity defined using the position property. By default, the direction is automatically calculated based on the distance to the edge of the window.

Additionally, adding the teleport property will move the content to the referenced DOM location instead of the current one.

html
<section class="odocs-spaced">
    <o-field>
        <o-switch v-model="teleport" label="Teleport to Body" />
    </o-field>

    <p>
        <o-popover position="right" :teleport="teleport">
            <o-button label="Right Popover" />

            <template #content>
                <h4 style="margin-top: 0">Heading</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur warning elit.
                    Fusce id fermentum quam
                </p>
                <a href="#">Some Link</a>
            </template>
        </o-popover>

        <o-popover position="top" :teleport="teleport">
            <o-button label="Top Popover" />

            <template #content>
                <h4 style="margin-top: 0">Heading</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur warning elit.
                    Fusce id fermentum quam
                </p>
                <a href="#">Some Link</a>
            </template>
        </o-popover>

        <o-popover position="bottom" :teleport="teleport">
            <o-button label="Bottom Popover" />

            <template #content>
                <h4 style="margin-top: 0">Heading</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur warning elit.
                    Fusce id fermentum quam
                </p>
                <a href="#">Some Link</a>
            </template>
        </o-popover>

        <o-popover position="left" :teleport="teleport">
            <o-button label="Left Popover" />

            <template #content>
                <h4 style="margin-top: 0">Heading</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur warning elit.
                    Fusce id fermentum quam
                </p>
                <a href="#">Some Link</a>
            </template>
        </o-popover>
    </p>
</section>
javascript
import { ref } from "vue";

const teleport = ref(false);

Delay

The appearance of the content can be delayed using the delay property.

html
<section>
    <o-popover content="The content is shown after 1000ms" :delay="1000">
        <o-button label="Delayed" />
    </o-popover>
</section>

Closeable

Using closeable a close button can be added to the content.

html
<section>
    <o-popover closeable behavior="manual">
        <template #default="{ open }">
            <o-button @click="open"> Open popover! </o-button>
        </template>

        <template #content>
            <b>Lorem ipsum dolor sit amet</b>, consectetur warning elit.
            <i>Fusce id fermentum quam</i>.
            <o-icon icon="heart" variant="danger" />
        </template>
    </o-popover>
</section>

Backdrop

The the backdrop property allows a full-page overlay to be added to the top-layer of the page. By default, attempting to interact with the backdrop will close the popover.

html
<section>
    <o-popover backdrop>
        <o-button> Open popover! </o-button>

        <template #content>
            <b>Lorem ipsum dolor sit amet</b>, consectetur warning elit.
            <i>Fusce id fermentum quam</i>.
            <o-icon icon="heart" variant="danger" />
        </template>
    </o-popover>
</section>

When the modal property is added, the popover appears in the middle of the screen as a modal-style overlay with a full-page backdrop. The position property is ignored when the modal property is used.

Accessibility Note:

The popover modal style is mainly useful for improving the mobile experience. If you want to create a true modal, the ODialog element is the way to go.

html
<section>
    <o-popover modal>
        <o-button> Open popover! </o-button>

        <template #content>
            <b>Lorem ipsum dolor sit amet</b>, consectetur warning elit.
            <i>Fusce id fermentum quam</i>.
            <o-icon icon="heart" variant="danger" />
        </template>
    </o-popover>
</section>

Programmatically

This component provides a programmatic interface that can be accessed by the useOruga() composable. The composable can be used from outside of the Vue instance. For example, it can be used in Pinia or Vue Router with this syntax:

js
import { useOruga } from "@oruga-ui/oruga-next";
const oruga = useOruga();
oruga.popover.open({...});

The programmatic popover composable requires a trigger property in order to define the target element to which the popover will be attached to.

A programmatic instance returns a promise to await for. The promise gets resolved when the popover gets closed.

html
<section class="odocs-spaced">
    <p>
        <o-button
            label="Open Text Popover"
            size="medium"
            variant="primary"
            @click="openTextPopover()" />

        <o-button
            label="Open Image Popover"
            size="medium"
            variant="primary"
            @click="openImagePopover()" />
    </p>

    <div ref="target" style="background-color: var(--vp-c-brand-3)">
        Container with programmatic popover
    </div>
</section>
javascript
import { h, useTemplateRef } from "vue";
import { useOruga } from "@oruga-ui/oruga-next";

const oruga = useOruga();

const target = useTemplateRef("target");

function openTextPopover(): void {
    oruga.popover.open(
        {
            // the target element the popover will be attached to
            target: target,
            content: "This overlay can have some usefull information.",
        },
        // placing target here again to mount the popover inside the target instead of body
        target,
    );
}

function openImagePopover(): void {
    // here we use a render function to create an dynamic inline component (https://vuejs.org/guide/extras/render-function)
    const vnode = h("img", {
        alt: "This is the Oruga Logo!",
        src: "https://avatars2.githubusercontent.com/u/66300512?s=200&v=4",
    });

    oruga.popover.open({
        target: target,
        position: "bottom",
        backdrop: true,
        component: vnode,
    });
}

Popover Component

A popover is a content container that displays rich content over the top of other content.

html
<o-popover></o-popover>

Props

Prop nameDescriptionTypeValuesDefault
activeWhether popover is active or not, use v-model:active to make it two-way bindingboolean-false
animationShow and dismiss animationstring-
From config:
popover: {
  animation: "fade"
}
ariaCloseLabelAccessibility label for the close buttonstring-
From config:
popover: {
  ariaCloseLabel: "Close"
}
backdropAdds a backdrop to the backgroundboolean-false
behaviorThe behavior of the popover."auto" | "hint" | "manual"auto, hint, manual"auto"
clipScrollSet true to remove the body scrollbar.
When false, a non-scrollable scrollbar will be kept to avoid moving the background,
but will set the body to a fixed position, which may break some layouts.
boolean-
From config:
popover: {
  clipScroll: false
}
closeIconClose icon namestring-
From config:
popover: {
  closeIcon: "close"
}
closeIconSizeClose icon sizestring-
From config:
popover: {
  closeIconSize: undefined
}
closeableAdds close button to the contentboolean-
From config:
popover: {
  closeable: false
}
componentComponent to be injected.
Close the component by emitting a 'close' event — $emit('close')
C-
contentContent body text, unnecessary when content slot is usedstring-
delayDefines a delay (in ms) before the content appearsnumber-
disabledThe component will be disabledboolean-false
eventsEvents to be binded to the injected componentEmitsToProps<ComponentEmit<C>>-
iconPackIcon pack to use for the close iconstringmdi, fa, fas and any other custom icon pack
From config:
popover: {
  iconPack: undefined
}
idA unique HTML id for the popover elementstring-useId()
modalDefines if the popover should be shown as centered modal - the position is ignored when trueboolean-false
overrideOverride existing theme classes completelyboolean-
positionThe position of the popover relative to the triggerPopoverPositiontop, bottom, left, right, center, [top, right], [top, left], [bottom, left], [bottom, right]
From config:
popover: {
  position: "top"
}
propsProps to be binded to the injected componentComponentProps<C>-
roleA role for the content element."dialog" | "menu" | "tooltip"-
targetDefine the target element to which the popover gets connected programmatically.MaybeElement-
teleportAppend the component to another part of the DOM.
Set true to append the component to the body.
In addition, any CSS selector string or an actual DOM node can be used.
boolean | object | string-
From config:
popover: {
  teleport: false
}
titleContent header title, unnecessary when title slot is usedstring-

Events

Event namePropertiesDescription
update:activevalue boolean - updated active propactive prop two-way binding
closeevent Event - native eventon active state changes to false
openevent Event - native eventon active state changes to true

Slots

NameDescriptionBindings
defaultDefine a trigger hereactive boolean - popover active state
open (): void - function to open the popover
titleOverride the popover title, default is title propclose (): void - function to close the popover
closeDefine a custom close icon
contentOverride the popover content, default is content propclose (): void - function to close the popover

Class Inspector

Classes applied to the element:
Want to know how does the Class Inspector work?
Class propDescriptionPropsSuffixes
rootClass
Class of the root element.
disabledClass
Class of the root element when disabled.
disabled
activeClass
Class of the root element when active.
active
teleportClass
Class of the root element when teleported.
teleport
contentClass
Class of the content element.
contentActiveClass
Class of the content element when active.
active
contentModalClass
Class of the content element when shown as modal.
modal
contentBackdropClass
Class of the content when should has a backdrop.
modal
headerClass
Class of the content header element.
title
bodyClass
Class of the content body element.
closeClass
Class of the close element.
scrollClipClass
Class of the body when is open and scroll is clipped.
clipScroll
scrollKeepClass
Class of the body when is open and scroll is keeped.
clipScroll

Sass Variables

Current theme ➜ Oruga

The theme does not have any custom variables for this component.

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

The theme does not have any custom variables for this component.

Released under the MIT License.