Popoverv1.0.9Documentation Under Review
A popup that displays rich content and interactive elements when a user clicks on a trigger element, with product-specific styling options.
The Popover component is built on top of Radix UI's Popover primitive. It provides a click-triggered overlay that displays rich content and interactive elements. The product variant supports custom styling for branded applications.
Installation
npm install @pmi/catalyst-popoverTailwind Config
The Popover package comes with a Tailwind preset that provides entrance animations for the component. Import this into your Tailwind configuration and add the preset to the presets array.
import type { Config } from 'tailwindcss';
import { default as tailwindPopoverPreset } from '@pmi/catalyst-popover/tailwind.config';
export default {
content: ['./src/**/*.{ts,tsx,js,jsx}', './node_modules/@pmi/catalyst-*/**/*.{ts,tsx,js,jsx}'],
theme: {},
presets: [tailwindPopoverPreset],
plugins: [],
} satisfies Config;The preset includes:
- Animations: Smooth slide and fade animations from all four directions
- Keyframes:
slideDownAndFade,slideUpAndFade,slideLeftAndFade,slideRightAndFade - Timing: 400ms cubic-bezier easing for smooth motion
Note: These are the same animations used by the Tooltip component.
Usage
import {
PopoverRoot,
PopoverTrigger,
PopoverContent,
PopoverArrow,
} from '@pmi/catalyst-popover';<PopoverRoot>
<PopoverTrigger>Click me</PopoverTrigger>
<PopoverContent>
Popover content
<PopoverArrow />
</PopoverContent>
</PopoverRoot>Popover vs Tooltip
| Feature | Popover | Tooltip |
|---|---|---|
| Trigger | Click | Hover/Focus |
| Content | Interactive (buttons, forms) | Informational only |
| Close | Click outside, Escape | Mouse leave, Blur |
| Use Case | Actions, selections | Brief help text |
Examples
Basic Popover
A simple click-triggered popover with text content.
Positioning
Control popover placement using side and align props.
With Icon Trigger
Use icons as popover triggers for compact UI elements.
Complex Content
Popovers can contain rich content including lists and formatted text.
With Portal
Render popover content in a portal outside the DOM hierarchy for better z-index control.
Custom Styling
Apply custom color palette for product-specific branded designs.
API Reference
PopoverRoot
The root component that manages popover state.
Prop
Type
PopoverTrigger
The button that opens the popover.
Prop
Type
PopoverContent
The popover content that appears.
Prop
Type
PopoverPortal
Renders the popover content in a portal (outside the DOM hierarchy).
Prop
Type
PopoverArrow
An optional arrow element that points to the trigger.
Prop
Type
PopoverAnchor
An optional element to position the popover against.
Prop
Type
PopoverClose
An optional button to close the popover.
Prop
Type
Accessibility
The Popover component follows WAI-ARIA best practices:
- Keyboard Navigation: Popovers open on click and can be navigated with Tab
- Escape Key: Pressing Escape dismisses the popover
- Focus Management: Focus can be managed within the popover content
- ARIA Attributes: Automatically applies proper
aria-expandedandaria-controls - Screen Readers: Content is announced when the popover opens
- Focus Trap: Optional modal mode traps focus within popover
Best Practices
- Click-Triggered: Popovers are click-triggered (use Tooltip for hover)
- Interactive Content: Use for forms, menus, or actionable content
- Close Mechanisms: Provide clear ways to close (outside click, Escape, close button)
- Focus Management: Add
tabIndex={0}to content elements for keyboard navigation - Avoid Nesting: Don't nest popovers within popovers
- Mobile Friendly: Ensure touch targets are large enough (minimum 44×44px)
- Custom Colors: When using custom styling, maintain sufficient contrast ratios (WCAG AA)
Related Components
- Tooltip - Hover-triggered overlay for supplementary info
- Dialog - Modal overlay for critical actions
- DropdownMenu - Menu-specific overlay
Drawer
A mobile-optimized bottom sheet component for product interfaces with full custom styling support. Built on Vaul with swipe gestures, scroll handling, and brand theming capabilities.
Sheet
A slide-out panel built on Radix UI Dialog with CVA side variants, modal and complementary modes, and full keyboard accessibility.