Popover

A panel anchored to its button. It grows from the button on a spring, flips when there is no room and closes on a press outside or Escape. Overlays.

Open playground

About

Popover is a React component in the Overlays category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Popover } from "@ashutoshswamy/smoui" and set trigger, triggerStyle, side among its 6 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Popover } from "@ashutoshswamy/smoui";

<Popover trigger="Share">
  <p>Anyone with the link can view.</p>
  <button data-close>Copy link</button>
</Popover>

Props 6

trigger / triggerClassName

The button that toggles it.

ReactNode / string
triggerStyle / triggerLabel

Optional trigger styling and accessible name.

CSSProperties / string
side / align

Placement. It flips if it would leave the screen.

"top""bottom" / "start""center""end"default "bottom" / "start"
width

Px.

numberdefault 260
open / onOpenChange

Controlled mode.

boolean / (open) => void
data-close

Put on any element inside to close the popover when it is clicked.

attribute