AisPopover
An AisPopover creates a floating element used to display additional information and controls. AisPopover is similar to AisTooltip but more expansive. A popover is triggered when users hover, click, or focus an element. Popovers are often positioned relative to the triggering element, but they can also be positioned relative to a separate target element.
Popover Creation
Popovers are created by one of three complementary methods -- directive, component, or composable. Each method exposes the same functionality but offers a different developer experience. At the heart of each method is a shared options object. AisPopover's props are valid keys on the options object.
v-popover
The v-popover directive is perhaps the simplest way to create a popover. It covers the case where the target and the trigger are the same (e.g. showing a popover when the user hovers over a button). Use v-popover with the title and content attributes to specify the popover details directly on the triggering element. v-popover will also accept an options object for deeper customization. If you're using Vue's Options API, please review the details for importing directives.
AisPopover
The next method to create a popover is to use the AisPopover component. The component allows developers to specify a popover as part of their template. The component's slots allow for more complex and customized content. If the popover contains interactive controls, you probably want the popover to appear on click. See the triggers prop for details.
Example of custom popover content
Selection: Grace Hopper
useAisPopover
The composable useAisPopover allows a developer to specify a popover completely in code. This method may be useful if you need to generate pieces of the popover or if you want to create multiple popovers in a single group. Both the directive and component call useAisPopover.
Props
All props are valid attributes on the options object which is passed to the directive and composable. On AisPopover the props are assembled into the options object and passed to useAisPopover.
target
The target prop specifies the DOM element that the popover is positioned against. Often it is the same element as the trigger, but they can be different. The target element may be specified by: ref, name, id, class, or a function that returns a DOM element.
trigger
The trigger prop specifies the DOM element that displays the popover based on the specified triggers. Often the triggering element is the same as the target but they can be different. If no trigger is specified, the target serves as the trigger.
Separate Target
triggers
The triggers prop controls how the popover is triggered. It accepts any combination of the user events hover, click, and focus. The default is triggers='hover focus'. To programmatically show and hide your popover, set triggers='manual'.
placement
The placement prop controls where the popover appears in relation to the target. The base placements are top, bottom, right, left. The default placement is top and the popover will center itself on the specified edge. Each of these base placements has an alignment in the form -start and -end (e.g. right-start or bottom-end). These allow you to align the popover to the target, rather than centering it.
variant
The variant prop accepts any of our standard display variants (e.g. success or danger). The default value is primary and typically a popover is the primary point of focus when it is displayed. In most cases primary should be preferred, but there may be times when you want to match the popover's variant with its target. You may play with different variant values in the example below.
arrow
arrow is a boolean prop that is on by default. To remove the little arrow widget on the popover, set arrow to false.
offset
offset sets the gap between the target and the popover. The default value is 9(px). Make sure you bind the value, so it is treated as a number (e.g. :offset="5").
maxWidth
The maxWidth prop will set a class to define the max width of the popover. The default value is max-w-md. Refer to Tailwind's max width utilities for other options.
showOnLoad
Add the showOnLoad boolean prop to show the popover on page load.
Slots
AisPopover has three slots – default, title, and target. These slots can be used to further customize your popover.
Content from default slot
Slot Demo
Content from default slot default
The default slot is used to define popover content. It is useful if you need rich formatting or templating in the popover, or if you want interactive controls on the popover.
title
The title slot is available to customize the title.
target
The target slot is available as another mechanism for associating the popover definition with a target DOM element. This is potentially useful if you are creating popovers in a loop and don't want to manage unique names or ids. In general however, we recommend using v-popover or the target prop instead.