> ## Documentation Index
> Fetch the complete documentation index at: https://prefab.prefect.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Popover

> Floating content panel triggered by clicking a child element.

export const ComponentPreview = ({json, height, resizable, bare, hideJson, playground, children}) => {
  const hostRef = React.useRef(null);
  const handleRef = React.useRef(null);
  const cardRef = React.useRef(null);
  const containerRef = React.useRef(null);
  const [previewWidth, setPreviewWidth] = React.useState(null);
  const [isDragging, setIsDragging] = React.useState(false);
  const [playgroundHref, setPlaygroundHref] = React.useState(null);
  React.useEffect(function () {
    if (!playground) return;
    var isLocal = location.hostname === "localhost" || location.hostname === "127.0.0.1";
    var path = isLocal ? "/playground" : "/docs/playground";
    var url = new URL(path, window.location.href);
    url.hash = "code=" + playground;
    setPlaygroundHref(url.href);
  }, [playground]);
  var jsonStr = typeof json === "string" ? json : JSON.stringify(json, null, 2);
  React.useEffect(function () {
    if (cardRef.current) {
      var card = cardRef.current.closest(".group");
      if (card) card.classList.remove("group");
    }
    var host = hostRef.current;
    if (!host || !json) return;
    function mount() {
      if (!window.__prefab || !host) return;
      var dark = document.documentElement.classList.contains("dark");
      handleRef.current = window.__prefab.mountPreview(host, jsonStr, {
        dark: dark
      });
      if (bare && host.shadowRoot) {
        var m = host.shadowRoot.querySelector("[data-prefab-mount]");
        if (m) m.style.background = "transparent";
      }
    }
    if (window.__prefab) {
      mount();
    } else {
      if (!window.__prefabLoading) {
        if (!window.__prefabReady) {
          var s = document.createElement("script");
          s.src = "/renderer.js";
          document.head.appendChild(s);
        }
        window.__prefabLoading = new Promise(function (resolve) {
          function check() {
            if (window.__prefabReady) {
              window.__prefabReady.then(resolve);
            } else {
              setTimeout(check, 10);
            }
          }
          check();
        });
      }
      window.__prefabLoading.then(mount);
    }
    var observer = new MutationObserver(function () {
      var dark = document.documentElement.classList.contains("dark");
      if (handleRef.current) handleRef.current.setDark(dark);
    });
    observer.observe(document.documentElement, {
      attributes: true,
      attributeFilter: ["class"]
    });
    return function () {
      observer.disconnect();
      if (handleRef.current) {
        handleRef.current.unmount();
        handleRef.current = null;
      }
    };
  }, [json]);
  function startResize(e) {
    e.preventDefault();
    var startX = e.clientX;
    var startW = hostRef.current ? hostRef.current.offsetWidth : 0;
    var maxW = containerRef.current ? containerRef.current.offsetWidth - 10 : startW;
    setIsDragging(true);
    function onMove(ev) {
      var w = Math.max(260, Math.min(startW + (ev.clientX - startX), maxW));
      setPreviewWidth(w);
    }
    function onUp() {
      document.removeEventListener("mousemove", onMove);
      document.removeEventListener("mouseup", onUp);
      setIsDragging(false);
    }
    document.addEventListener("mousemove", onMove);
    document.addEventListener("mouseup", onUp);
  }
  if (bare) {
    return <div ref={hostRef} />;
  }
  if (resizable) {
    return <Card>
        <div ref={cardRef} />
        <div ref={containerRef} style={{
      display: "flex",
      position: "relative",
      overflow: "hidden"
    }}>
          <div ref={hostRef} style={{
      flex: previewWidth ? "none" : 1,
      width: previewWidth ? previewWidth + "px" : undefined,
      minWidth: 0
    }} />
          <div onMouseDown={startResize} style={{
      width: "14px",
      flexShrink: 0,
      cursor: "col-resize",
      background: isDragging ? "var(--border, #e5e7eb)" : "color-mix(in srgb, var(--border, #e5e7eb) 40%, transparent)",
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      transition: "background 0.15s",
      userSelect: "none"
    }}>
            <svg width="6" height="24" style={{
      opacity: 0.5
    }}>
              <circle cx="2" cy="4" r="1.2" fill="currentColor" />
              <circle cx="2" cy="9" r="1.2" fill="currentColor" />
              <circle cx="2" cy="14" r="1.2" fill="currentColor" />
              <circle cx="2" cy="19" r="1.2" fill="currentColor" />
              <circle cx="5" cy="4" r="1.2" fill="currentColor" />
              <circle cx="5" cy="9" r="1.2" fill="currentColor" />
              <circle cx="5" cy="14" r="1.2" fill="currentColor" />
              <circle cx="5" cy="19" r="1.2" fill="currentColor" />
            </svg>
          </div>
          <div style={{
      flex: previewWidth ? 1 : "0 0 24px",
      minWidth: "24px",
      background: "repeating-linear-gradient(-45deg, transparent, transparent 3px, var(--border, #e5e7eb) 3px, var(--border, #e5e7eb) 4px)",
      opacity: 0.4
    }} />
          {previewWidth && <div style={{
      position: "absolute",
      bottom: "8px",
      right: "8px",
      background: "var(--background, white)",
      border: "1px solid var(--border, #e5e7eb)",
      borderRadius: "4px",
      padding: "1px 6px",
      fontSize: "11px",
      fontFamily: "monospace",
      color: "var(--muted-foreground, #6b7280)",
      pointerEvents: "none"
    }}>
              {previewWidth}px
            </div>}
        </div>
        {playgroundHref && <div style={{
      display: "flex",
      justifyContent: "flex-end",
      padding: "4px 0 8px"
    }}>
            <a href={playgroundHref} target="_blank" rel="noopener noreferrer" style={{
      fontSize: "11px",
      opacity: 0.4,
      textDecoration: "none",
      textDecorationLine: "none",
      borderBottom: "none",
      boxShadow: "none",
      display: "inline-flex",
      alignItems: "center",
      gap: "3px",
      transition: "opacity 0.15s",
      fontWeight: 400
    }} onMouseOver={function (e) {
      e.currentTarget.style.opacity = "0.6";
    }} onMouseOut={function (e) {
      e.currentTarget.style.opacity = "0.4";
    }}>
              Edit in Playground
              <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M15 3h6v6" /><path d="M10 14 21 3" /><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /></svg>
            </a>
          </div>}
        <div style={{
      marginBottom: "-2rem"
    }}>{children}</div>
      </Card>;
  }
  return <Card>
      <div ref={cardRef} />
      <div ref={hostRef} />
      {playgroundHref && <div style={{
    display: "flex",
    justifyContent: "flex-end",
    padding: "4px 0 8px"
  }}>
          <a href={playgroundHref} target="_blank" rel="noopener noreferrer" style={{
    fontSize: "11px",
    opacity: 0.4,
    textDecoration: "none",
    textDecorationLine: "none",
    borderBottom: "none",
    boxShadow: "none",
    display: "inline-flex",
    alignItems: "center",
    gap: "3px",
    transition: "opacity 0.15s",
    fontWeight: 400
  }} onMouseOver={function (e) {
    e.currentTarget.style.opacity = "0.6";
  }} onMouseOut={function (e) {
    e.currentTarget.style.opacity = "0.4";
  }}>
            Edit in Playground
            <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M15 3h6v6" /><path d="M10 14 21 3" /><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /></svg>
          </a>
        </div>}
      <div style={{
    marginBottom: "-2rem"
  }}>{children}</div>
    </Card>;
};

Popovers display rich content in a floating panel when users click a trigger element. The first child becomes the trigger; all remaining children become the panel content. Unlike [Tooltip](/components/tooltip) and [HoverCard](/components/hover-card), which appear on hover, Popovers require a click and stay open until the user clicks outside — making them ideal for forms, settings, and menus.

## Basic Usage

<ComponentPreview height="340px" json={{"view":{"type":"Popover","title":"Babel Fish Settings","description":"Configure your universal translator.","children":[{"type":"Button","label":"Open popover","variant":"outline","size":"default","disabled":false},{"cssClass":"gap-3","type":"Column","children":[{"type":"Label","text":"Source Language","optional":false},{"name":"input_15","type":"Input","inputType":"text","placeholder":"Vogon","disabled":false,"readOnly":false,"required":false},{"type":"Label","text":"Target Language","optional":false},{"name":"input_16","type":"Input","inputType":"text","placeholder":"Galactic Standard","disabled":false,"readOnly":false,"required":false}]}]}}} playground="ZnJvbSBwcmVmYWJfdWkuY29tcG9uZW50cyBpbXBvcnQgKAogICAgQnV0dG9uLAogICAgQ29sdW1uLAogICAgSW5wdXQsCiAgICBMYWJlbCwKICAgIFBvcG92ZXIsCikKCndpdGggUG9wb3Zlcih0aXRsZT0iQmFiZWwgRmlzaCBTZXR0aW5ncyIsIGRlc2NyaXB0aW9uPSJDb25maWd1cmUgeW91ciB1bml2ZXJzYWwgdHJhbnNsYXRvci4iKToKICAgIEJ1dHRvbigiT3BlbiBwb3BvdmVyIiwgdmFyaWFudD0ib3V0bGluZSIpCiAgICB3aXRoIENvbHVtbihnYXA9Myk6CiAgICAgICAgTGFiZWwoIlNvdXJjZSBMYW5ndWFnZSIpCiAgICAgICAgSW5wdXQocGxhY2Vob2xkZXI9IlZvZ29uIikKICAgICAgICBMYWJlbCgiVGFyZ2V0IExhbmd1YWdlIikKICAgICAgICBJbnB1dChwbGFjZWhvbGRlcj0iR2FsYWN0aWMgU3RhbmRhcmQiKQo">
  <CodeGroup>
    ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    from prefab_ui.components import (
        Button,
        Column,
        Input,
        Label,
        Popover,
    )

    with Popover(title="Babel Fish Settings", description="Configure your universal translator."):
        Button("Open popover", variant="outline")
        with Column(gap=3):
            Label("Source Language")
            Input(placeholder="Vogon")
            Label("Target Language")
            Input(placeholder="Galactic Standard")
    ```

    ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    {
      "view": {
        "type": "Popover",
        "title": "Babel Fish Settings",
        "description": "Configure your universal translator.",
        "children": [
          {
            "type": "Button",
            "label": "Open popover",
            "variant": "outline",
            "size": "default",
            "disabled": false
          },
          {
            "cssClass": "gap-3",
            "type": "Column",
            "children": [
              {"type": "Label", "text": "Source Language", "optional": false},
              {
                "name": "input_15",
                "type": "Input",
                "inputType": "text",
                "placeholder": "Vogon",
                "disabled": false,
                "readOnly": false,
                "required": false
              },
              {"type": "Label", "text": "Target Language", "optional": false},
              {
                "name": "input_16",
                "type": "Input",
                "inputType": "text",
                "placeholder": "Galactic Standard",
                "disabled": false,
                "readOnly": false,
                "required": false
              }
            ]
          }
        ]
      }
    }
    ```
  </CodeGroup>
</ComponentPreview>

## Without Header

Skip the `title` and `description` to render content directly in the panel.

<ComponentPreview height="260px" json={{"view":{"type":"Popover","children":[{"type":"Button","label":"Settings","variant":"outline","size":"default","disabled":false},{"cssClass":"gap-3","type":"Column","children":[{"type":"Label","text":"Improbability Factor","optional":false},{"name":"improbability","value":42.0,"type":"Slider","min":0.0,"max":100.0,"disabled":false,"size":"default"}]}]},"state":{"improbability":42.0}}} playground="ZnJvbSBwcmVmYWJfdWkuY29tcG9uZW50cyBpbXBvcnQgKAogICAgQnV0dG9uLAogICAgQ29sdW1uLAogICAgTGFiZWwsCiAgICBQb3BvdmVyLAogICAgU2xpZGVyLAopCgp3aXRoIFBvcG92ZXIoKToKICAgIEJ1dHRvbigiU2V0dGluZ3MiLCB2YXJpYW50PSJvdXRsaW5lIikKICAgIHdpdGggQ29sdW1uKGdhcD0zKToKICAgICAgICBMYWJlbCgiSW1wcm9iYWJpbGl0eSBGYWN0b3IiKQogICAgICAgIFNsaWRlcihtaW49MCwgbWF4PTEwMCwgdmFsdWU9NDIsIG5hbWU9ImltcHJvYmFiaWxpdHkiKQo">
  <CodeGroup>
    ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    from prefab_ui.components import (
        Button,
        Column,
        Label,
        Popover,
        Slider,
    )

    with Popover():
        Button("Settings", variant="outline")
        with Column(gap=3):
            Label("Improbability Factor")
            Slider(min=0, max=100, value=42, name="improbability")
    ```

    ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    {
      "view": {
        "type": "Popover",
        "children": [
          {
            "type": "Button",
            "label": "Settings",
            "variant": "outline",
            "size": "default",
            "disabled": false
          },
          {
            "cssClass": "gap-3",
            "type": "Column",
            "children": [
              {"type": "Label", "text": "Improbability Factor", "optional": false},
              {
                "name": "improbability",
                "value": 42.0,
                "type": "Slider",
                "min": 0.0,
                "max": 100.0,
                "disabled": false,
                "size": "default"
              }
            ]
          }
        ]
      },
      "state": {"improbability": 42.0}
    }
    ```
  </CodeGroup>
</ComponentPreview>

## Positioning

Control which side the panel appears on with the `side` prop:

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
from prefab_ui.components import Button, Popover, Text

with Popover(title="Guide Entry", side="right"):
    Button("Click for info", variant="outline")
    Text("A towel is about the most massively useful thing an interstellar hitchhiker can have.")
```

The renderer auto-adjusts if the popover would overflow the viewport, so the `side` is a preference rather than a hard constraint.

## Inline Confirmation

For lighter-weight confirmations that don't need a full modal overlay, a Popover works well. The same trigger-then-content pattern applies.

<ComponentPreview json={{"view":{"type":"Popover","children":[{"type":"Button","label":"Archive","variant":"outline","size":"default","disabled":false},{"cssClass":"gap-2","type":"Column","children":[{"content":"Archive this item?","type":"Text"},{"type":"Button","label":"Confirm","variant":"default","size":"default","disabled":false,"onClick":[{"action":"toolCall","tool":"archive_item","arguments":{"id":"{{ item_id }}"}},{"action":"closeOverlay"}]}]}]}}} playground="ZnJvbSBwcmVmYWJfdWkuY29tcG9uZW50cyBpbXBvcnQgQnV0dG9uLCBDb2x1bW4sIFBvcG92ZXIsIFRleHQKZnJvbSBwcmVmYWJfdWkuYWN0aW9ucyBpbXBvcnQgQ2xvc2VPdmVybGF5CmZyb20gcHJlZmFiX3VpLmFjdGlvbnMubWNwIGltcG9ydCBDYWxsVG9vbApmcm9tIHByZWZhYl91aS5yeCBpbXBvcnQgUngKCml0ZW1faWQgPSBSeCgiaXRlbV9pZCIpCgp3aXRoIFBvcG92ZXIoKToKICAgIEJ1dHRvbigiQXJjaGl2ZSIsIHZhcmlhbnQ9Im91dGxpbmUiKQogICAgd2l0aCBDb2x1bW4oZ2FwPTIpOgogICAgICAgIFRleHQoIkFyY2hpdmUgdGhpcyBpdGVtPyIpCiAgICAgICAgQnV0dG9uKAogICAgICAgICAgICAiQ29uZmlybSIsCiAgICAgICAgICAgIG9uX2NsaWNrPVsKICAgICAgICAgICAgICAgIENhbGxUb29sKCJhcmNoaXZlX2l0ZW0iLCBhcmd1bWVudHM9eyJpZCI6IGl0ZW1faWR9KSwKICAgICAgICAgICAgICAgIENsb3NlT3ZlcmxheSgpLAogICAgICAgICAgICBdLAogICAgICAgICkK">
  <CodeGroup>
    ```python Python icon="python" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    from prefab_ui.components import Button, Column, Popover, Text
    from prefab_ui.actions import CloseOverlay
    from prefab_ui.actions.mcp import CallTool
    from prefab_ui.rx import Rx

    item_id = Rx("item_id")

    with Popover():
        Button("Archive", variant="outline")
        with Column(gap=2):
            Text("Archive this item?")
            Button(
                "Confirm",
                on_click=[
                    CallTool("archive_item", arguments={"id": item_id}),
                    CloseOverlay(),
                ],
            )
    ```

    ```json Protocol icon="brackets-curly" theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
    {
      "view": {
        "type": "Popover",
        "children": [
          {
            "type": "Button",
            "label": "Archive",
            "variant": "outline",
            "size": "default",
            "disabled": false
          },
          {
            "cssClass": "gap-2",
            "type": "Column",
            "children": [
              {"content": "Archive this item?", "type": "Text"},
              {
                "type": "Button",
                "label": "Confirm",
                "variant": "default",
                "size": "default",
                "disabled": false,
                "onClick": [
                  {
                    "action": "toolCall",
                    "tool": "archive_item",
                    "arguments": {"id": "{{ item_id }}"}
                  },
                  {"action": "closeOverlay"}
                ]
              }
            ]
          }
        ]
      }
    }
    ```
  </CodeGroup>
</ComponentPreview>

## API Reference

<Card icon="code" title="Popover Parameters">
  <ParamField body="title" type="str | None" default="None">
    Optional header title for the popover panel.
  </ParamField>

  <ParamField body="description" type="str | None" default="None">
    Optional description below the title.
  </ParamField>

  <ParamField body="side" type="str | None" default="None">
    Preferred side to show the popover: `"top"`, `"right"`, `"bottom"`, `"left"`.
  </ParamField>

  <ParamField body="css_class" type="str | None" default="None">
    Additional Tailwind CSS classes.
  </ParamField>
</Card>

## Protocol Reference

```json Popover theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
{
  "type": "Popover",
  "id?": "string",
  "onMount?": "any",
  "children?": "[Component]",
  "let?": "object",
  "title?": "string",
  "description?": "string",
  "side?": "top | right | bottom | left",
  "cssClass?": "string"
}
```

For the complete protocol schema, see [Popover](/protocol/popover).
