Skip to content

Overlays

Popover

tsx
import { Button, Popover } from "@cherry-design-system/react";

export function SharePreview() {
  return (
    <>
      <Button variant="outline" popoverTarget="share">Share</Button>
      <Popover id="share" title="Share preview">
        Anyone with the link can view it.
      </Popover>
    </>
  );
}

Popover is a non-modal floating panel anchored to the button that opens it. It runs on the native popover attribute and CSS anchor positioning, so it needs no client JavaScript: point a button at it with popoverTarget and the browser opens, closes and light-dismisses it. For a list of actions use Menu; for a short hover hint use Tooltip.

Examples

Actions

actions adds a row of buttons at the bottom, aligned to the end. A button with popoverTarget and the native popoverTargetAction="hide" closes the popover without JavaScript.

tsx
import { Button, Popover } from "@cherry-design-system/react";

export function Publish() {
  return (
    <>
      <Button popoverTarget="publish">Publish</Button>
      <Popover
        id="publish"
        title="Publish changes?"
        actions={
          <Button variant="outline" size="sm" popoverTarget="publish" popoverTargetAction="hide">
            Not now
          </Button>
        }
      >
        Your changes go live for everyone.
      </Popover>
    </>
  );
}

Placement

placement picks the side of the trigger and align the alignment along it.

tsx
import { Button, Popover } from "@cherry-design-system/react";

export function Help() {
  return (
    <>
      <Button variant="ghost" popoverTarget="help">Help</Button>
      <Popover id="help" placement="right" align="start">
        Press ⌘K to search.
      </Popover>
    </>
  );
}

Manual mode

mode="manual" keeps the popover open until it is told to close (by its trigger or a popoverTargetAction="hide" button), instead of closing on Escape, an outside click or another popover opening.

tsx
import { Button, Popover } from "@cherry-design-system/react";

export function Pinned() {
  return (
    <>
      <Button popoverTarget="notes">Notes</Button>
      <Popover id="notes" mode="manual" title="Notes">
        Stays open while you work.
      </Popover>
    </>
  );
}

Properties

idstringrequired

The trigger points at it with popoverTarget={id}.

placement"left" | "right" | "top" | "bottom"

Side of the trigger it opens on. Defaults to "bottom".

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

Alignment along that side. Defaults to "center".

titleReactNode

Heading; also the popover's accessible name.

actionsReactNode

Buttons at the bottom, aligned to the end.

mode"auto" | "manual"

"auto" closes on Escape, an outside click or another popover opening; "manual" only closes when told to. Defaults to "auto".

Popover renders a <div> with the popover attribute, forwards its ref and passes other <div> attributes through. It is safe in Server Components.

Styling

HookValues
Classcherry-popover
data-placementtop, bottom, left, right
data-alignstart, center, end
States:popover-open
Partscherry-popover__title, cherry-popover__body, cherry-popover__actions

The panel reads --cherry-bg-elevated, --cherry-border-default, --cherry-radius-xl and --cherry-elevation-lg.

Accessibility

Popover is non-modal: Escape and outside clicks close it and focus returns to the trigger. With title it is a labelled dialog. Open it from a real <button> with popoverTarget so the browser wires the relationship.