MazPopover
MazPopover is a versatile Vue component for displaying content in overlays that bypass overflow constraints of parent elements
Basic usage
Adaptive trigger
The adaptive trigger mode automatically adapts to the user's device:
- Desktop: Uses hover behavior (mouseenter/mouseleave)
- Mobile/Touch devices: Uses click behavior
This provides the best user experience across all devices without requiring manual configuration.
Positions
TIP
The position prop is used to position the popover relative to the trigger. The chosen position will force the popover to be displayed in the chosen position.
Advanced positions
Prefer position and fallback position
TIP
The prefer-position and fallback-position props are used to position the popover relative to the trigger. The prefer-position is the position that will be used if it's available, and the fallback-position is the position that will be used if the prefer-position is not available.
When you not specify a fallback position, the popover will fallback on the best position available.
Colors
Tooltip role
A directive is available to more easily add a tooltip to an element, see vTooltip for more information.
Controlled popover
Menu example
Keep open on hover
With this option, the popover will stay open when you hover over it (a timeout is used to close the popover after a certain time).
Form example
Configuration options
Persistent (no auto-close)
Custom offset
Custom styling
Disabled state
Events
Event Log:
Position values
auto- Automatically choose best positiontop,bottom,left,right- Basic positionstop-start,top-end- Top with start/end alignmentbottom-start,bottom-end- Bottom with start/end alignmentleft-start,left-end- Left with start/end alignmentright-start,right-end- Right with start/end alignment
Accessibility
MazPopover follows WAI-ARIA guidelines:
- Focus management: Automatically manages focus when opening/closing
- Keyboard navigation: Supports Escape key and Tab navigation
- ARIA attributes: Proper
role,aria-modal,aria-labelledby, etc. - Screen reader support: Appropriate roles for different use cases
- Trigger ARIA on the real control:
aria-expanded,aria-haspopupandaria-controlsare set on the interactive element of thetriggerslot (your button, link...), never on a wrapper around it. ARIA attributes you set yourself on that element are kept, and acomboboxkeeps managing its own state. When the slot has no interactive element, the wrapper becomes a focusablebutton(Enter / Space toggle the popover).
Best practices
- Use
role="tooltip"for simple informational overlays - Use
role="dialog"for interactive content - Provide meaningful
aria-labelledbyoraria-describedbyattributes - Ensure trigger elements are focusable and have proper labels
Props
| Name | Description | Type | Required | Default | Possible values |
|---|---|---|---|---|---|
| model-value | v-model Controls the popover open state | boolean | No | false | - |
| position | Position of the popover relative to trigger - Position of the popover relative to trigger | MazPopoverPosition | No | "auto" | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' |
| prefer-position | Preferred position of the popover relative to trigger when auto position is used - Preferred position of the popover relative to trigger | MazPopoverPreferPosition | No | 'bottom-start' | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' |
| fallback-position | Fallback position of the popover relative to trigger when prefer position is not visible - Fallback position of the popover relative to trigger | MazPopoverFallbackPosition | No | auto | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end' |
| trigger | How the popover is triggered - How the popover is triggered. 'adaptive' uses hover on desktop and click on mobile | MazPopoverTrigger | No | "click" | 'click' | 'hover' | 'manual' | 'adaptive' |
| role | ARIA role for accessibility - ARIA role for accessibility | MazPopoverRole | No | "dialog" | 'dialog' | 'tooltip' |
| aria-label | ARIA label for the popover | string | No | - | - |
| announce-changes | Announce content changes to screen readers | boolean | No | false | - |
| disabled | Disables the popover - Disables the popover | boolean | No | false | - |
| offset | Distance between trigger and popover in pixels | number | No | 8 | - |
| delay | Delay before showing/hiding in milliseconds | number | No | 0 | - |
| hover-delay | Delay before closing on hover in milliseconds | number | No | 150 | - |
| transition | CSS transition name for animations - 'scale-pop' | 'scale-fade' for default transitions. 'scale-pop' is a pop effect, 'scale-fade' is a fade effect. | string | No | "scale-pop" | 'scale-pop' | 'scale-fade' | 'string' |
| teleport-to | Teleport target selector | string | No | "body" | - |
| overlay-class | Additional CSS classes for the overlay wrapper | ClassValue | No | - | - |
| panel-class | Additional CSS classes for the popover panel | ClassValue | No | - | - |
| panel-style | Inline styles for the popover panel | StyleValue | No | - | - |
| close-on-click-outside | Close popover when clicking outside | boolean | No | true | - |
| close-on-escape | Close popover when pressing Escape key | boolean | No | true | - |
| persistent | Prevent auto-close (ignores click outside and escape key) | boolean | No | false | - |
| id | Custom ID for the popover element | string | No | - | - |
| aria-labelledby | ARIA labelledby attribute for accessibility | string | No | - | - |
| aria-describedby | ARIA describedby attribute for accessibility | string | No | - | - |
| color | Color variant of the popover | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent" | "surface" | No | "surface" | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'destructive' | 'contrast' | 'transparent' | 'surface' |
| trap-focus | Trap focus inside the popover | boolean | No | true | - |
| keep-open-on-hover | Keep popover open when hovering over the panel | boolean | No | false | - |
| block | The popover will be full width of the trigger | boolean | No | false | - |
| position-reference | CSS selector or element reference to use for positioning calculations - When provided, the popover will position relative to this element instead of the trigger Useful for components with labels where you want to position relative to the actual input | string | HTMLElement | No | - | - |
Events
| Event name | Payload | Description |
|---|---|---|
| update:model-value | value: boolean | Emitted when popover state changes |
| open | - | Emitted when popover opens |
| close | - | Emitted when popover closes |
| toggle | value: boolean | Emitted when popover toggles |
| update:modelValue | value: boolean | |
| after-close-animation | - | Emitted after the close animation |
Slots
| Name | Description | Bindings |
|---|---|---|
| trigger | Trigger element content | open () => void - Function to open the popoverclose () => void - Function to close the popovertoggle () => void - Function to toggle the popoverisOpen boolean - Current open state of the popovertrigger "click" | "hover" | "manual" - The trigger type |
| default | Popover content | open () => void - Function to open the popoverclose () => void - Function to close the popovertoggle () => void - Function to toggle the popoverisOpen true - Current open state of the popover |
Expose
open
Open the popover
close
Close the popover
toggle
Toggle the popover
isOpen
Check if the popover is open
updatePosition
Update the popover position
panelRef
Panel reference