Skip to Content
NarakUI

Popover

A floating panel that appears on demand, containing supplementary content or actions.

Basic usage

A controlled popover with a title, a description, and actions. Pass open and onOpenChange when an action inside should close it.

Explanation

An uncontrolled popover that explains a metric. It closes on Escape or a click outside. Widen it with className.

Form

A short form for a quick edit. Focus moves into the popover when it opens and returns to the trigger when it closes. align="start" lines it up with the trigger's left edge.

Installation

pnpm dlx shadcn@latest add @narakui/popover

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/popover.json.

Usage

import { Button } from '@/components/ui/button';
import { Popover } from '@/components/ui/popover';

<Popover.Root>
  <Popover.Trigger asChild>
    <Button>Open</Button>
  </Popover.Trigger>
  <Popover.Content className="p-3">
    <p className="text-body-small-regular text-text-secondary">
      Supplementary content or quick actions.
    </p>
  </Popover.Content>
</Popover.Root>;

Popover.Content is 256px wide (w-64) with no horizontal padding. It aligns to the end of the trigger unless you pass align. Use Popover.Anchor to position the content against an element other than the trigger.

Popover.Root

PropTypeDefaultDescription
openboolean—Whether the popover is open
onOpenChange(open: boolean) => void—Callback when the open state changes
defaultOpenbooleanfalseDefault open state
modalbooleanfalseWhether the popover should be modal

Popover.Content

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''bottom'Preferred side of the trigger to render against
sideOffsetnumber10Distance in pixels from the trigger
align'start' | 'center' | 'end''end'Alignment of the popover content
alignOffsetnumber-5Additional offset in pixels for the alignment
avoidCollisionsbooleantrueWhether the popover should avoid collisions with viewport edges
collisionBoundaryElement | null | Array<Element | null>—Elements to use as collision boundaries
collisionPaddingnumber | Partial<Record<Side, number>>12Padding to add to collision boundaries
arrowPaddingnumber0Padding between the arrow and the edges of the popover
sticky'partial' | 'always''partial'Whether the popover should stick to the trigger
hideWhenDetachedbooleanfalseWhether to hide the popover when the trigger becomes detached
withRadixPortalbooleantrueRender the content through a Radix Portal
classNamestring—Additional CSS classes to apply to the popover content