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 playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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.
numberdefault260- open / onOpenChange
Controlled mode.
boolean / (open) => void- data-close
Put on any element inside to close the popover when it is clicked.
attribute
More overlays components
- CommandPaletteCmd+K palette. Type to filter, arrows move one highlight that stretches between rows, Enter runs.
- ConfirmPopoverA small are-you-sure that opens beside its button instead of taking over the page. A failed action stays open and says so.
- ContextMenuRight-click, long-press or press the Menu key for a menu that opens out of the exact point you pressed. It flips to stay on screen and moves with the arrow keys.
- DialogA modal that grows out of its trigger, traps focus and keeps its header and footer in view while long content scrolls. Alert mode guards destructive decisions; the confirm button handles async work and failure itself.
- DropdownA menu with one highlight that stretches between rows. Arrow keys, Home and End move it, Enter picks, Escape closes.
- HoverCardA card that opens when you rest on a name, stays while you move onto it and closes when you leave.