Popover

Alignment target:@astryxdesign/core v0.7.1 · Popover

Usage #

Popover opens a surface next to a trigger button. The surface holds short, interactive content such as a form, a short message, or an action list. The trigger is the default slot and the surface is the content slot.

Vue
<script setup lang="ts">
import { Button } from '@astryx-vue/core/Button'
import { Popover } from '@astryx-vue/core/Popover'
</script>

<template>
  <Popover label="Project details">
    <Button label="Details" variant="secondary" />
    <template #content>
      <p>Short content goes here.</p>
    </template>
  </Popover>
</template>

Anatomy

ElementDescription
Trigger elementCaller-supplied or externally referenced control that anchors and toggles the popover.
Popover surfacePainted surface owned and themed by Popover through the canonical popover target.
Popover contentCaller-supplied content rendered inside the surface.
Fallback close controlKeyboard-reachable close affordance appended by usePopover when enabled.

Best practices #

GuidancePractices
DoKeep popover content focused on a single task or piece of information.
DoProvide a clear way to close: either by clicking outside or with an explicit close button.
Don'tNest popovers inside other popovers; it creates confusing focus and navigation.
Don'tUse a popover for content that requires heavy user input; use a Dialog instead.
Don'tPut too much content in a popover; if it needs scrolling, use a Dialog instead.

Examples #

Popover — Bottom sheet alternative

Project actions

Use this modal touch surface when the task should move away from its trigger and stay close to the bottom edge.
Open in Playground

On a compact touch surface, project actions open in a bottom sheet instead of an anchored popover.

Popover — Confirm action

Open in Playground

A destructive button opens a short confirmation with Delete and Cancel.

Popover — Filter panel

Open in Playground

Status checkboxes with Apply and Reset.

Popover — Keyboard shortcuts

Open in Playground

A list of shortcut keys and what they do.

Popover — Settings panel

Open in Playground

Switches for notifications, dark mode, and sounds.

Accessibility #

A popover has to communicate its presence, its current open state, and its content to people who use a screen reader or a keyboard. The component links the trigger to the surface automatically and manages focus as the surface opens and closes, so you only need to supply the accessible name.

  • The trigger receives aria-haspopup, aria-expanded, and aria-controls, so assistive technology knows it is a button that opens a surface and can announce whether that surface is currently expanded.
  • A dialog surface has role="dialog"; when isModal is set it also has aria-modal="true", and the label serves as its accessible name.
  • Focus moves to the first focusable element inside the surface on open, and returns to the trigger when the user presses Escape or closes the surface.
  • With isModal set, Tab focus stays inside the surface while it is open.
  • The built-in close button is visually hidden until it receives focus, so it appears once the keyboard reaches it.

Layout #

The surface is positioned with JavaScript. It recalculates its position when the page scrolls or resizes, and it flips to the other side when the chosen side has no room.