To source

Atrium // Components

Popover

A popover.

<script setup lang="ts">
import "@atrium-ui/elements/popover";
import Button from "./Button.vue";

defineProps<{
  label?: string;
}>();
</script>

<template>
  <a-popover-trigger class="relative z-10">
    <div slot="trigger">
      <Button v-if="label" slot="trigger" variant="outline">
        {{ label }}
      </Button>
      <slot v-else name="input" />
    </div>

    <a-popover class="group">
      <div class="w-[max-content] p-2 opacity-0 transition-opacity duration-100 group-[&[enabled]]:opacity-100">
        <div
          :class="[
            'min-w-[180px] rounded-xl border border-zinc-950/10 bg-white p-1.5 text-sm',
            'shadow-[0_1px_2px_rgb(0_0_0/0.04),0_8px_24px_-4px_rgb(0_0_0/0.12)]',
            'dark:border-white/10 dark:bg-zinc-900 dark:shadow-[0_1px_2px_rgb(0_0_0/0.3),0_8px_24px_-4px_rgb(0_0_0/0.5)]',
            'scale-95 transition-all duration-150 group-[&[enabled]]:scale-100',
          ]"
        >
          <slot />
        </div>
      </div>
    </a-popover>
  </a-popover-trigger>
</template>

"A tooltip is a popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it. It typically appears after a small delay and disappears when Escape is pressed or on mouse out."

Example

Click the button to open the popover. This type of popover is a modal popover, so the rest of the page is blocked.

Tooltip

In this example, the popover opens when the pointer hovers over the button. This type of popover is a non-modal popover, so the rest of the page is not blocked.

Accessibility

  • Escape always dismisses the popover.
  • Aria attributes indicate the role and state.
  • Popovers can be modal or non-modal. Non-modal popovers do not block interactions on the page while it is open.

References