Popover
A floating panel that opens when its trigger is clicked, placed on one of four sides and closed by an outside click or Escape.
<arc-popover>Overview
Popover opens a panel of any content when the reader clicks its trigger. Use it for info cards, filter panels and small forms. For a panel that opens on hover, use HoverCard, and for a short hint, use Tooltip.
Put the trigger in the trigger slot and the content in the default slot. position (top, bottom, left or right, default bottom) picks the preferred side. The panel is drawn in the top layer, so overflow: hidden ancestors can't clip it, and it flips to the opposite side or shifts along the edge when it doesn't fit in the viewport. It scales in on --transition-base.
Clicking outside or pressing Escape closes it. The component fires arc-open and arc-close. The panel has role="dialog" and the trigger gets aria-haspopup and aria-expanded.
Guidelines
Do
- Use a focusable element, like a button, in the `trigger` slot so keyboard users can open it
- Keep the content short. Use Dialog or Drawer for complex forms, tables or long lists
- Links, buttons and small forms are fine inside the panel
Don't
- Don't put information readers must see in a popover. It's easy to close by accident
Features
- Escape returns focus to the element that had it when the panel opened
- Parts: `base`, `trigger`, `panel`
Preview
Details
Click outside or press Escape to close.
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</arc-popover>import { Popover } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</Popover>
);
}<script setup>
import { Popover } from '@arclux/arc-ui-vue';
</script>
<template>
<Popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</Popover>
</template><script>
import { Popover } from '@arclux/arc-ui-svelte';
</script>
<Popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</Popover>import { Component } from '@angular/core';
import { Popover } from '@arclux/arc-ui-angular';
@Component({
imports: [Popover],
template: `
<arc-popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</arc-popover>
`,
})
export class MyComponent {}import { Popover } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</Popover>
);
}import { Popover } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Popover>
<button slot="trigger">Show Popover</button>
<div>Popover content here.</div>
</Popover>
);
}API
triggerstring''- Deprecated, and has no effect: it was reserved for trigger modes that were never built, and v5 removes it. For a panel that opens on hover, use
arc-hover-card. openbooleanfalse- Whether the popover panel is currently visible. Reflected as an attribute.
position'top' | 'bottom' | 'left' | 'right''bottom'- Placement of the panel relative to the trigger element.
Events
arc-open- Fired when the popover opens.
arc-close- Fired when the popover closes.