Skip to content

React Popover

A glass React popover anchored to its trigger, for small forms and details; Escape or a click outside closes it. Use Popover as a glass popover for a small filter panel opened from a toolbar button, where a few controls and an Apply action fit in a panel anchored to the button.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/popover.json

Document

  • Popover
  • PopoverClose
  • PopoverTitle
  • PopoverContent
  • PopoverTrigger
  • +5 more
  • +2 more

Files to copy

5 folders · 6 files · 4 packages
From theme/src/
  • components/popover/
  • components/drawer/parts/sheet.tsx
  • hooks/{use-latest.ts, use-media-query.ts}
  • lib/{cn.ts, form.ts, popup-motion.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/popover.jsonRegistry item: popover. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/input/
  • components/spinner/
  • hooks/{use-magnetic.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{field-size.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/input.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Placement and a controlled panel

side and align place the panel; open and onOpenChange let your code close it after saving.

Bottom sheet on phones

mobile='sheet' presents the panel as a bottom sheet under 640px wide, modal with a drag handle and swipe-to-dismiss. The default, 'popup', keeps the anchored panel. Press “Preview on a phone” to try it on a desktop screen (or narrow the window).

Props

PropTypeDefaultDescription
modalboolean | "trap-focus"false (a sheet: true)Traps focus and locks scroll while open (Base UI's modal). A sheet is modal unless you set this.
mobileMobilePresentation"popup"How the panel opens on a phone-width screen (max-width: 640px): "popup" is the usual panel next to the trigger; "sheet" is a bottom sheet with a drag handle, swipe-down to dismiss, a scrollable body capped at 85 dvh and home-indicator padding. Escape closes and focus returns to the trigger in both.
Popover open / defaultOpenbooleanfalseControls whether the popover is open (open), or sets its initial state (defaultOpen).
PopoverTrigger renderReactElementNoneRender as your own element, e.g. render={<Button />}.
PopoverContent side"top" | "bottom" | "left" | "right""bottom"Side of the trigger it opens on.
PopoverContent align"start" | "center" | "end""center"Sets the alignment along that side.
PopoverContent sideOffsetnumber (px)8Gap between the trigger and the popover.
Popover ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example onOpenChange, onOpenChangeComplete, actionsRef, modal, triggerId, defaultTriggerId).
PopoverTrigger ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example nativeButton, id, className, style, handle, payload).
PopoverContent ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example style, className, render, initialFocus, finalFocus).

PopoverContent props

PropTypeDefaultDescription
labelsPartial<PopoverLabels>defaultPopoverLabelsSpoken text. Merged over defaultPopoverLabels. Every other string, for translation: labels={{ close: "…" }}; omitted keys keep the English of defaultPopoverLabels. Its only key is listed in the key table under the props table.
side"top" | "bottom" | "left" | "right""bottom"Preferred side of the trigger. It flips when there is no room.
align"center" | "end" | "start""center"Sets the alignment along that side.
sideOffsetnumber8Gap between trigger and panel, in px.
PopoverLabels keys and English defaults (1)
Pass any key in labels; the rest keep the defaults of defaultPopoverLabels.
KeyEnglish default
closeClose

Keyboard

KeysAction
Enter/SpaceOpen or close it from the trigger; focus moves into the panel.
Tab/Shift + TabCycle inside the panel.
EscapeClose it and return focus to the trigger.

Accessibility

  • The trigger gets aria-expanded and aria-haspopup; the panel is labeled by PopoverTitle when you render one.
  • Use a Popover for interactive content; use a Tooltip for a short label and a HoverCard for a preview.
  • Under reduced motion the panel only fades.

All exports on this page

  • Popover — Glass popover: a small floating panel anchored to a button, for extra controls or details that do not deserve a full dialog.
  • PopoverClose — A button inside PopoverContent that closes the popover (for "Done" or "Cancel" actions).
  • PopoverContent — The glass panel of a Popover, portalled to the end of the body and positioned next to the trigger.
  • PopoverDescription — Muted helper text under the title.
  • PopoverTitle — The popover's heading.
  • PopoverTrigger — The element that opens a Popover.
  • defaultPopoverLabels — English defaults of PopoverLabels.

When to use Popover

  • Use Popover for a Filters or Share button in a toolbar that opens a compact panel with a few fields and a confirm action, kept next to the button so the page behind stays in view.
  • Use it for an account menu with a profile summary and a sign out button, or a share panel with a link field, where content stays near the trigger.
  • Use side, align and sideOffset on PopoverContent to place the panel, knowing it flips to the other side when there is no room in the viewport.
  • Skip it when the content is a plain hint or a list of commands. Use Tooltip for a label on hover, Menu for actions, and Dialog when the task needs the whole page's attention.
  • Pair it with Button through the render prop on PopoverTrigger, Field and Switch for settings inside the panel, and Calendar when a date picker needs custom content.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .