Skip to content
synccn

Popover

Floating panel anchored to a trigger.

Installation

$ pnpm dlx shadcn@latest add @synccn/popover

First time in this project? Connect synccn with one command.

Usage

import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";<Popover>  <PopoverTrigger><Button>Open</Button></PopoverTrigger>  <PopoverContent>…</PopoverContent></Popover>

API reference

Generated from the component's TypeScript types, so it always matches the code.

Popover

  • open
    boolean

    Controlled open state.

  • defaultOpen
    boolean

    Default false

    Initial state when uncontrolled.

  • onOpenChange
    (open: boolean) => void

    Called when it opens or closes.

  • children
    React.ReactNode

    Content to render.

  • className
    string

    Extra classes for the root element.

PopoverTrigger

Pass a single element; it receives onClick + aria props.

  • childrenrequired
    React.ReactElement<any>

    A single element that toggles the popover.

PopoverContent

  • side
    "top" | "bottom" | "left" | "right"

    Default "bottom"

    Side of the trigger to open on.

  • align
    "start" | "center" | "end"

    Default "center"

    Alignment along that side.

  • className
    string

    Extra classes for the root element.

  • children
    React.ReactNode

    Content to render.

Also accepts every standard <div> attribute, and forwards its ref.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseClickOutside (closes on an outside click), useControllable (works controlled or uncontrolled), useEscape (closes on Escape), usePresence (animates in and out)

npm packages

Keyboard

  • EscClose

Accessibility

  • The trigger gets aria-expanded and aria-haspopup automatically.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: dialog
  • Closes with Escape
  • Closes when you click or tap outside