# Popover

An anchored dialog with form content, keyboard focus and bounded scrolling.

Access: pro. Category: Feedback. Kind: primitive.

## When to use

- Use it when a product interface needs an anchored dialog with form content, keyboard focus and bounded scrolling.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose alert instead when inline notices with icons, actions and optional dismissal is the actual interface need, rather than popover.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Popover

```sh
npx shadcn@latest add @tidal-pro/popover
```

Stylesheets: `components/ui/tidal.css`, `components/ui/popover.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/popover.css";
import{TidalPopover}from"./components/ui/popover";
export default()=><div className="tidal-scope"><TidalPopover/></div>;
```

## Structured props

- `TidalPopover.dir?: "ltr" | "rtl" | undefined` (default "ltr"): Optional dir value accepted by this exported component.
- `TidalPopover.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.
- `TidalPopoverContent.title: string`: Required title value accepted by this exported component.
- `TidalPopoverContent.closeLabel?: string | undefined` (default "Close popover"): Optional close label value accepted by this exported component.
- `TidalPopoverContent.description?: string | undefined`: Optional description value accepted by this exported component.
- `TidalPopoverContent.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalPopoverContent.showClose?: boolean | undefined` (default true): Optional show close value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/popover.tsx) | [Manifest](https://tidalui.com/examples/popover.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useState, useRef, useId, type CSSProperties } from "react";

import { Folder, Share2, LockKeyhole, Eye, PenLine, UserRound, Plus, Check, RotateCcw } from "lucide-react";

import { TidalPopover, TidalPopoverTrigger, TidalPopoverContent, TidalPopoverClose } from "./components/ui/popover";

import { TidalButton } from "./components/ui/tidal-button";

import { TidalField } from "./components/ui/form-field";

import { TidalSegmentedControl } from "./components/ui/segmented-control";

import "./components/ui/popover.css";

import "./components/ui/form-field.css";

import "./components/ui/segmented-control.css";

function tidalExampleAvatarDataUri(seed: unknown) {
  const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI";
  const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"];
  const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length];
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><rect width="96" height="96" rx="48" fill="${color}"/><circle cx="48" cy="38" r="17" fill="white" fill-opacity=".92"/><path d="M18 92c3-22 15-34 30-34s27 12 30 34" fill="white" fill-opacity=".92"/></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

function tidalExampleImageDataUri(label: string) {
  const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image";
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 675"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop stop-color="#171717"/><stop offset="1" stop-color="#555555"/></linearGradient></defs><rect width="1200" height="675" fill="url(#g)"/><circle cx="950" cy="100" r="260" fill="white" fill-opacity=".08"/><text x="80" y="570" fill="white" font-family="system-ui,sans-serif" font-size="64" font-weight="700">${safeLabel}</text></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

const tidalExampleStyles = ".tidal-scope .popover-specimen{width:100%;max-width:640px;padding:28px;border:1px solid var(--t-border);border-radius:var(--t-radius-card);background:var(--t-surface);box-shadow:0 18px 36px -28px #00000030}\n.tidal-scope .popover-specimen>h3{font-size:29px;line-height:1.1;letter-spacing:-1px;font-weight:500;margin:14px 0 26px}.tidal-scope .popover-specimen>h3 em{font:italic 37px/1.1 \"Instrument Serif\",Georgia,serif;letter-spacing:-.8px}\n.tidal-scope .popover-demo-workspace{border:1px solid var(--t-border);border-radius:16px;overflow:hidden;background:var(--t-subtle)}\n.tidal-scope .popover-demo-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;padding:12px 16px;border-bottom:1px solid var(--t-border);background:var(--t-surface)}\n.tidal-scope .popover-demo-toolbar>span{display:flex;align-items:center;gap:9px;font-size:12px;font-weight:550;min-width:0}.tidal-scope .popover-demo-toolbar .tidal-popover-trigger{font-size:11px;flex-shrink:0;padding:0 11px}\n.tidal-scope .popover-demo-paper{padding:24px;min-width:0;background:linear-gradient(140deg,#2a2a2a,#151515);color:#f2f2f2;box-shadow:inset 0 1px 0 #ffffff09;position:relative}\n.tidal-scope .popover-demo-paper-top{display:flex;justify-content:space-between;gap:10px;font-size:11px;color:#b3b3b3;letter-spacing:1px}.tidal-scope .popover-demo-paper h4{font-size:17px;font-weight:500;letter-spacing:-.4px;margin:30px 0 10px}\n.tidal-scope .popover-demo-paper>p{font-size:25px;line-height:1.2;letter-spacing:-.7px;color:#f2f2f2;margin:0}.tidal-scope .popover-demo-paper>p em{font:italic 30px/1.2 \"Instrument Serif\",Georgia,serif}\n.tidal-scope .popover-demo-notes{display:grid;gap:7px;margin:22px 0 27px}.tidal-scope .popover-demo-notes>span{display:block;height:2px;background:#ffffff19;border-radius:3px;width:100%;transition:width 460ms var(--t-ease-out)}.tidal-scope .popover-demo-notes>span:nth-child(2){width:76%}.tidal-scope .popover-demo-notes>span:last-child{width:54%}.tidal-scope .popover-specimen[data-access=edit] .popover-demo-notes>span:nth-child(2){width:93%}.tidal-scope .popover-specimen[data-access=edit] .popover-demo-notes>span:last-child{width:68%}\n.tidal-scope .popover-demo-people{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid #ffffff15;padding-top:17px}.tidal-scope .popover-demo-avatars{display:flex;gap:6px;flex-shrink:0}.tidal-scope .popover-demo-avatars>span{display:grid;place-items:center;width:32px;height:32px;border:2px solid #1b1b1b;border-radius:50%;margin-inline-start:0;background:#dedede;color:#282828;animation:popover-member-enter 500ms var(--t-ease-spring) both;animation-delay:calc(var(--member-index)*40ms)}.tidal-scope .popover-demo-avatars>span:nth-child(2){background:#aaaaaa}.tidal-scope .popover-demo-avatars>span:nth-child(3){background:#7e7e7e;color:#ffffff}.tidal-scope .popover-demo-avatars>span:nth-child(4){background:#ffffff;box-shadow:0 0 0 3px #ffffff13}\n.tidal-scope .popover-demo-member-reading{display:flex;align-items:center;gap:6px;font-size:11px;color:#cecece}.tidal-scope .popover-demo-count{height:1.12em;overflow:hidden;font-size:17px;font-weight:550;color:#ffffff;display:inline-block;line-height:1.12}.tidal-scope .popover-demo-count>span{display:flex;flex-direction:column;transition:transform 520ms var(--t-ease-spring)}.tidal-scope .popover-demo-count>span>span{height:1.12em;line-height:1.12;flex:none}\n.tidal-scope .popover-demo-access{display:flex;align-items:center;gap:12px;padding:16px;background:var(--t-surface);border-top:1px solid var(--t-border)}.tidal-scope .popover-demo-access-icon{display:grid;place-items:center;position:relative;width:36px;height:36px;border:1px solid var(--t-border);border-radius:9px;background:var(--t-subtle);flex-shrink:0}.tidal-scope .popover-demo-access-icon svg{grid-area:1/1;transition:opacity 200ms,transform 360ms var(--t-ease-spring)}.tidal-scope .popover-demo-access-icon svg:last-child{opacity:0;transform:translateY(6px) scale(.7)}.tidal-scope .popover-specimen[data-access=edit] .popover-demo-access-icon svg:first-child{opacity:0;transform:translateY(-6px) scale(.7)}.tidal-scope .popover-specimen[data-access=edit] .popover-demo-access-icon svg:last-child{opacity:1;transform:none}.tidal-scope .popover-demo-access small{display:block;font-size:11px;letter-spacing:.8px;color:var(--t-muted);margin-bottom:5px}.tidal-scope .popover-demo-access strong{display:block;font-size:11px;font-weight:500}.tidal-scope .popover-demo-access-badge{margin-inline-start:auto;font-size:11px;white-space:nowrap;padding:5px 7px;border:1px solid var(--t-border);border-radius:6px;background:var(--t-subtle)}\n.tidal-scope .popover-demo-bottom{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:15px}.tidal-scope .popover-demo-bottom>p{font-size:11px;line-height:1.6;color:var(--t-muted);max-width:270px}.tidal-scope .popover-demo-bottom .tidal-button{font-size:11px;padding-inline:10px;flex-shrink:0}.tidal-scope .popover-demo-note{font-size:11px;color:var(--t-muted);margin-top:12px;line-height:1.7}\n.tidal-scope .popover-demo-form>.tidal-button{width:100%;margin-top:10px;font-size:11px}.tidal-scope .popover-demo-permission{margin-top:22px}.tidal-scope .popover-demo-permission>.demo-eyebrow{display:block;margin-bottom:9px}.tidal-scope .popover-demo-permission>p{font-size:11px;color:var(--t-muted);margin:9px 0 0;line-height:1.6}.tidal-scope .popover-demo-guest{display:flex;align-items:center;gap:10px;padding:13px 0;border-top:1px solid var(--t-border);border-bottom:1px solid var(--t-border);margin-top:18px}.tidal-scope .popover-demo-guest>span{display:grid;place-items:center;width:32px;height:32px;border:1px solid var(--t-border);border-radius:8px;background:var(--t-subtle);color:var(--t-muted)}.tidal-scope .popover-demo-guest>div{flex:1;min-width:0}.tidal-scope .popover-demo-guest strong{display:block;font-size:12px;font-weight:500;overflow-wrap:anywhere}.tidal-scope .popover-demo-guest small{display:block;font-size:11px;color:var(--t-muted);margin-top:4px}.tidal-scope .popover-demo-guest[data-added=true]>span{background:var(--t-ink);color:var(--t-surface);animation:popover-member-enter 420ms var(--t-ease-spring)}.tidal-scope .popover-demo-pop-status{font-size:11px;color:var(--t-muted);margin:12px 0 0;line-height:1.6}.tidal-scope .popover-demo-footer{display:flex;align-items:center;justify-content:space-between;gap:12px}.tidal-scope .popover-demo-footer>span{display:flex;align-items:center;gap:6px;color:var(--t-muted);font-size:11px}\n@media(max-width:600px){.tidal-scope .popover-specimen{padding:18px}.tidal-scope .popover-demo-toolbar{padding:10px;gap:8px}.tidal-scope .popover-demo-toolbar>span{font-size:11px;gap:6px}.tidal-scope .popover-demo-toolbar .tidal-popover-trigger{font-size:11px;padding-inline:9px}.tidal-scope .popover-demo-paper{padding:18px}.tidal-scope .popover-demo-paper>p{font-size:21px}.tidal-scope .popover-demo-paper>p em{font-size:26px}.tidal-scope .popover-demo-access{padding:12px;gap:9px}.tidal-scope .popover-demo-access-badge{font-size:11px}.tidal-scope .popover-demo-member-reading{font-size:11px}}\n@keyframes popover-member-enter{from{opacity:0;transform:translateY(7px) scale(.8)}to{opacity:1;transform:none}}\n@media(prefers-reduced-motion:reduce){.tidal-scope .popover-specimen *,.tidal-scope .popover-demo-guest *{animation:none!important;transition:none!important}.tidal-scope .popover-demo-avatars>span{transform:none}}\n\n.tidal-scope .popover-demo-avatars>span{overflow:hidden}.tidal-scope .popover-demo-avatars img{width:100%;height:100%;object-fit:cover;filter:grayscale(1)}";

export function PopoverDemo({ theme = "light" }: { theme?: "light" | "dark" }) {
  const [open, setOpen] = useState(false),
    [permission, setPermission] = useState("view"),
    [name, setName] = useState(""),
    [guest, setGuest] = useState(""),
    [error, setError] = useState(""),
    [status, setStatus] = useState("Open Share to edit the sample access.");
  const field = useRef<HTMLInputElement>(null),
    id = useId(),
    count = 3 + Number(Boolean(guest));
  const edit = permission === "edit";
  return (
    <section
      className="popover-specimen"
      data-access={permission}
      data-open={open}
    >
      <div className="popover-demo-workspace">
        <div
          className="popover-demo-toolbar"
          role="group"
          aria-label="Sample workspace actions"
        >
          <span>
            <Folder size={15} aria-hidden="true" />
            Northstar
          </span>
          <TidalPopover theme={theme} open={open} onOpenChange={setOpen}>
            <TidalPopoverTrigger>
              <Share2 size={14} aria-hidden="true" />
              Share
            </TidalPopoverTrigger>
            <TidalPopoverContent
              title="Share Northstar"
              description="Choose access for this local preview. Nothing is sent."
              align="end"
              footer={
                <div className="popover-demo-footer">
                  <span>
                    <LockKeyhole size={12} aria-hidden="true" />
                    Local sample
                  </span>
                  <TidalPopoverClose>
                    Done
                    <Check size={13} aria-hidden="true" />
                  </TidalPopoverClose>
                </div>
              }
            >
              <form
                className="popover-demo-form"
                noValidate
                onSubmit={(event) => {
                  event.preventDefault();
                  if (name.trim().length < 2) {
                    setError("Use at least two characters.");
                    field.current?.focus({ preventScroll: true });
                    return;
                  }
                  setGuest(name.trim());
                  setName("");
                  setError("");
                  setStatus(
                    guest
                      ? `Sample guest updated to ${name.trim()}. Nothing was sent.`
                      : `Sample guest ${name.trim()} added. Nothing was sent.`,
                  );
                }}
              >
                <TidalField
                  ref={field}
                  id={id + "-guest"}
                  label="Guest name"
                  value={name}
                  onChange={(event) => {
                    setName(event.target.value);
                    setError("");
                  }}
                  maxLength={32}
                  required
                  error={error || undefined}
                  placeholder="e.g. Casey"
                  autoComplete="off"
                />
                <TidalButton type="submit">
                  <Plus size={14} aria-hidden="true" />
                  {guest ? "Update sample guest" : "Add sample guest"}
                </TidalButton>
              </form>
              <div className="popover-demo-permission">
                <span className="demo-eyebrow">SAMPLE GUEST ACCESS</span>
                <TidalSegmentedControl
                  label="Sample guest permission"
                  value={permission}
                  onValueChange={(value) => {
                    setPermission(value);
                    setStatus(
                      `${value === "edit" ? "Editor" : "Viewer"} access selected for this sample.`,
                    );
                  }}
                  options={[
                    { value: "view", label: "Viewer" },
                    { value: "edit", label: "Editor" },
                  ]}
                />
                <p>
                  {edit
                    ? "Guests can change this sample workspace."
                    : "Guests can read this sample workspace."}
                </p>
              </div>
              <div className="popover-demo-guest" data-added={Boolean(guest)}>
                <span>
                  <UserRound size={16} aria-hidden="true" />
                </span>
                <div>
                  <strong>{guest || "Room for one more"}</strong>
                  <small>
                    {guest
                      ? `Sample guest · ${edit ? "Editor" : "Viewer"}`
                      : "Add a fictional teammate above."}
                  </small>
                </div>
                {guest ? <Check size={15} aria-hidden="true" /> : null}
              </div>
              <p className="popover-demo-pop-status">{status}</p>
            </TidalPopoverContent>
          </TidalPopover>
        </div>
        <article
          className="popover-demo-paper"
          aria-label="Shared sample workspace"
        >
          <div className="popover-demo-paper-top">
            <span>PROJECT BRIEF</span>
            <span>DRAFT</span>
          </div>
          <h4>Product launch</h4>
          <p>
            Scope and milestones.
            <br />
            <em>Prepared for review.</em>
          </p>
          <div className="popover-demo-notes" aria-hidden="true">
            <span />
            <span />
            <span />
          </div>
          <div className="popover-demo-people">
            <div
              className="popover-demo-avatars"
              role="group"
              aria-label="Fictional teammates"
            >
              {["Ava", "Noah", "Mila", ...(guest ? [guest] : [])].map(
                (person, index) => (
                  <span
                    key={person + "-" + index}
                    title={person}
                    role="img"
                    aria-label={person}
                    style={{ "--member-index": index } as CSSProperties}
                  >
                    <img
                      src={tidalExampleAvatarDataUri(String(index + 1).padStart(2, "0"))}
                      alt=""
                      width={32}
                      height={32}
                    />
                  </span>
                ),
              )}
            </div>
            <span className="popover-demo-member-reading">
              <span className="sr-only">{count} members</span>
              <span className="popover-demo-count" aria-hidden="true">
                <span style={{ transform: `translateY(${-count * 1.12}em)` }}>
                  {Array.from({ length: 10 }, (_, i) => (
                    <span key={i}>{i}</span>
                  ))}
                </span>
              </span>
              <span aria-hidden="true">members</span>
            </span>
          </div>
        </article>
        <div className="popover-demo-access">
          <span className="popover-demo-access-icon">
            <Eye size={16} aria-hidden="true" />
            <PenLine size={16} aria-hidden="true" />
          </span>
          <div>
            <small>SAMPLE LINK ACCESS</small>
            <strong>{edit ? "Editor access" : "Viewer access"}</strong>
          </div>
          <span className="popover-demo-access-badge">
            {edit ? "Can edit" : "Can view"}
          </span>
        </div>
      </div>
      <div className="popover-demo-bottom">
        <p role="status">{status}</p>
        <TidalButton
          variant="ghost"
          aria-label="Reset sharing sample"
          onClick={() => {
            setGuest("");
            setPermission("view");
            setName("");
            setError("");
            setStatus("Open Share to edit the sample access.");
          }}
        >
          <RotateCcw size={14} aria-hidden="true" />
          Reset
        </TidalButton>
      </div>
      <p className="popover-demo-note">
        Fictional members and permissions. No invitation, link sharing or
        storage.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <PopoverDemo />
    </div>
  );
}

```

## Gotchas

- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-popover-offset-x","--t-popover-offset-y","--t-popover-viewport-height","--t-popover-viewport-width","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Compound Radix Popover1.2.0 family. TidalPopover forwards Root open/defaultOpen/onOpenChange/modal (Radix default non-modal), with theme(light default) and dir(ltr default) for its Portal. Consumers own state, forms, validation, requests and permissions. Trigger forwards native button props/ref/disabled/asChild; Anchor forwards the Radix positioning anchor/asChild/ref. Content requires a visible title, supports optional description/footer/showClose(defaulttrue)/closeLabel(defaultClose popover), and forwards native Content positioning, events, focus and DOM ref, including React19 callback-ref cleanup and legacy null callbacks. Content owns its styled DOM and Portal, so asChild/forceMount are intentionally omitted and no extra Portal is needed. Its generated heading/description IDs compose with external aria-labelledby/aria-describedby. Use matching theme/dir explicitly on Root. Default sideOffset9 and collisionPadding12, bounded width and visual-viewport height; individual horizontal/vertical placement correction keeps a tall surface inside a phone keyboard viewport without replacing Radix entry transforms. Mounted surface/body ResizeObserver and scoped Popper-wrapper style observation/listeners clean up on close; ordinary pointer/touch body scrolling is not snapped back to focus. Resize preserves the focused body control inside its nearest scroller without scrolling the document. Fixed header/footer, internally scrolling body,44px trigger/dismiss/actions and visible focus. Optional modal=true traps focus; default non-modal permits outside interaction and focus-away dismissal. Enter/Space opens a button trigger, Tab follows native controls, Escape/outside/Close dismiss with Radix focus return; caller preventDefault handlers compose and can prevent dismissal. TidalPopoverClose forwards native button props/ref/asChild and introduces no confirmation or action. Required accessible naming, caller-owned keyboard behavior inside children and consumer form labels remain essential. Scoped tidal.css/popover.css and finite trigger/surface motion honor reduced motion. No sharing, email, invite, storage, entitlement or network operation is introduced.

## Theme and accessibility

Override --t-* tokens. Use data-theme="dark" on the scope for dark surfaces. Respect prefers-reduced-motion. Preserve native keyboard behavior and visible focus. Demo data is sample data.
