Skip to main content
ninna-ui

Popover

A floating panel anchored to a trigger element.

import { Popover } from "@ninna-ui/overlays"
pnpm add @ninna-ui/overlays

Requires @ninna-ui/core (auto-installed) + CSS setup.

View source

Usage

Import and use the Popover component in your application.

import { Popover } from "@ninna-ui/overlays";
import { Button , Code } from "@ninna-ui/primitives";
export default function Example() {
return (
<Popover>
<Popover.Trigger asChild>
<Button variant="outline">Open Popover</Button>
</Popover.Trigger>
<Popover.Content>
<p>Popover content here</p>
<Popover.Arrow />
</Popover.Content>
</Popover>
);
}

Basic

A basic popover with title and description.

Placements

Position the popover on any side of the trigger element.

Alignment

Align the popover to the start, center, or end of the trigger.

With Arrow

Add an arrow pointer to visually connect the popover to its trigger.

Rich Content

Popovers can contain rich layouts like user profiles and cards.

API Reference

Complete list of props for the Popover component and its sub-components.

Popover (Root)

PropTypeDefaultDescription
children*ReactNode-Popover content (Trigger, Content, etc.)
openboolean-Controlled open state
defaultOpenbooleanfalseDefault open state (uncontrolled)
onOpenChange(open: boolean) => void-Callback when open state changes
modalbooleanfalseWhether the popover is modal

Popover.Content

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''bottom'Which side to place the popover
sideOffsetnumber4Distance from trigger in pixels
align'start' | 'center' | 'end''center'Alignment along the side
avoidCollisionsbooleantrueWhether to avoid collisions with viewport boundary
onEscapeKeyDown(event: KeyboardEvent) => void-Callback when Escape key is pressed
onPointerDownOutside(event: Event) => void-Callback when pointer clicks outside content
onFocusOutside(event: Event) => void-Callback when focus moves outside content
classNamestring-Additional CSS classes

Popover.Trigger

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of wrapping button

Popover.Arrow

PropTypeDefaultDescription
widthnumber10Width of the arrow in pixels
heightnumber5Height of the arrow in pixels

Popover.Close

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of default close button

Accessibility

  • Popover content is associated with trigger via aria-controls
  • Focus moves to content when opened and returns to trigger when closed
  • Escape key dismisses the popover
  • Clicking outside the popover dismisses it
  • Arrow keys navigate focusable elements within the popover