# Popover

Non-modal content anchored to a trigger.

Non-modal content anchored to a trigger.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/popover">Base UI Popover</a> for upstream
  behavior and configuration. Zenos owns the public API, styling, and composition shown on this
  page.
</p>

```tsx
import { Button, Popover } from "@zentara-co/zenos-ui";

function PopoverExample() {
  return (
    <Popover.Root>
      <Popover.Trigger render={<Button variant="primary" />}>Filters</Popover.Trigger>
      <Popover.Content side="bottom" align="end" arrow>
        <Popover.Header>
          <Popover.Title>Asset filters</Popover.Title>
          <Popover.Description>Limit the visible asset set.</Popover.Description>
        </Popover.Header>
        <Popover.Footer>
          <Popover.Close variant="primary">Apply filters</Popover.Close>
        </Popover.Footer>
      </Popover.Content>
    </Popover.Root>
  );
}
```

## Anatomy

Use `Content` for the common portal, positioning, collision, and popup composition. `Header` groups the accessible title and description; `Footer` provides responsive spacing for actions.

```tsx
<Popover.Root>
  <Popover.Trigger render={<Button variant="primary" />}>Details</Popover.Trigger>
  <Popover.Content arrow>
    <Popover.Header>
      <Popover.Title>Workspace details</Popover.Title>
      <Popover.Description>Current access and ownership.</Popover.Description>
    </Popover.Header>
    <Popover.Footer>
      <Popover.Close>Done</Popover.Close>
    </Popover.Footer>
  </Popover.Content>
</Popover.Root>
```

## Import

```tsx
import { Button, Popover } from "@zentara-co/zenos-ui";
```

Popover uses `open`, `defaultOpen`, and `onOpenChange`. Content manages portal, positioner, and popup composition. Its default surface matches Dropdown Menu in both light and dark themes. Add the `arrow` prop when the popup needs a directional arrow; it is omitted by default. The popup and arrow share the same 150ms enter and exit motion so the arrow does not lag behind the surface. Escape and outside interaction close the popover according to Base UI behavior.

## Controlled state

Control open state when the trigger label or another part of the interface needs to reflect visibility.

```tsx
import { Button, Popover, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function PopoverControlledExample() {
  const [open, setOpen] = useState(false);
  return (
    <Stack gap="3" align="center">
      <Popover.Root open={open} onOpenChange={setOpen}>
        <Popover.Trigger render={<Button variant="primary" />}>
          {open ? "Details open" : "Show details"}
        </Popover.Trigger>
        <Popover.Content arrow>
          <Popover.Header>
            <Popover.Title>Finding details</Popover.Title>
            <Popover.Description>Detected on the public API endpoint.</Popover.Description>
          </Popover.Header>
          <Popover.Footer>
            <Popover.Close>Done</Popover.Close>
          </Popover.Footer>
        </Popover.Content>
      </Popover.Root>
      <Text size="s" color="subtle">
        Popover is {open ? "open" : "closed"}.
      </Text>
    </Stack>
  );
}
```

## Placement

`side` is the preferred side and may flip when collision avoidance detects insufficient space. `align` positions the popup along the selected side.

```tsx
import { Button, Popover, Stack } from "@zentara-co/zenos-ui";

function PopoverPlacementExample() {
  return (
    <Stack direction="row" gap="4" align="center" wrap="wrap" justify="center">
      <Popover.Root>
        <Popover.Trigger render={<Button variant="primary" />}>Top start</Popover.Trigger>
        <Popover.Content side="top" align="start" arrow>
          <Popover.Header>
            <Popover.Title>Top placement</Popover.Title>
            <Popover.Description>Aligned to the start of the trigger.</Popover.Description>
          </Popover.Header>
        </Popover.Content>
      </Popover.Root>
      <Popover.Root>
        <Popover.Trigger render={<Button variant="primary" />}>Bottom center</Popover.Trigger>
        <Popover.Content side="bottom" align="center" arrow>
          <Popover.Header>
            <Popover.Title>Bottom placement</Popover.Title>
            <Popover.Description>Centered on the trigger.</Popover.Description>
          </Popover.Header>
        </Popover.Content>
      </Popover.Root>
      <Popover.Root>
        <Popover.Trigger render={<Button variant="primary" />}>Right end</Popover.Trigger>
        <Popover.Content side="right" align="end" arrow>
          <Popover.Header>
            <Popover.Title>Right placement</Popover.Title>
            <Popover.Description>Aligned to the end of the trigger.</Popover.Description>
          </Popover.Header>
        </Popover.Content>
      </Popover.Root>
    </Stack>
  );
}
```

## Interactive content

Popover is non-modal and works well for compact controls that need an anchored surface. Keep longer workflows in Dialog or a dedicated page.

```tsx
import { Button, Checkbox, Label, Popover, Stack } from "@zentara-co/zenos-ui";
import { useState } from "react";

function PopoverFilterExample() {
  const [criticalOnly, setCriticalOnly] = useState(false);
  const [includeArchived, setIncludeArchived] = useState(false);
  return (
    <Popover.Root>
      <Popover.Trigger render={<Button variant="primary" />}>Asset filters</Popover.Trigger>
      <Popover.Content align="start" arrow>
        <Popover.Header>
          <Popover.Title>Asset filters</Popover.Title>
          <Popover.Description>Limit the assets shown in this view.</Popover.Description>
        </Popover.Header>
        <Stack gap="3" className="my-4">
          <Label className="cursor-pointer">
            <Checkbox checked={criticalOnly} onCheckedChange={setCriticalOnly} />
            Critical findings only
          </Label>
          <Label className="cursor-pointer">
            <Checkbox checked={includeArchived} onCheckedChange={setIncludeArchived} />
            Include archived assets
          </Label>
        </Stack>
        <Popover.Footer className="mt-0">
          <Popover.Close variant="primary">Apply filters</Popover.Close>
        </Popover.Footer>
      </Popover.Content>
    </Popover.Root>
  );
}
```

## Motion

Popovers fade, scale, and move from their resolved side when opening, then reverse that movement when closing. Reduced-motion preferences remove the animation automatically. The arrow fades with the popup.

Open each popover. The first animates in and out. `disableMotion` makes the second appear and disappear immediately.

```tsx
import { Button, Grid, Popover } from "@zentara-co/zenos-ui";

function PopoverMotionExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      <Popover.Root>
        <Popover.Trigger render={<Button variant="primary" />}>With motion</Popover.Trigger>
        <Popover.Content>
          <Popover.Header>
            <Popover.Title>Asset filters</Popover.Title>
            <Popover.Description>Limit the visible asset set.</Popover.Description>
          </Popover.Header>
        </Popover.Content>
      </Popover.Root>
      <Popover.Root>
        <Popover.Trigger render={<Button variant="primary" />}>Without motion</Popover.Trigger>
        <Popover.Content disableMotion>
          <Popover.Header>
            <Popover.Title>Asset filters</Popover.Title>
            <Popover.Description>Limit the visible asset set.</Popover.Description>
          </Popover.Header>
        </Popover.Content>
      </Popover.Root>
    </Grid>
  );
}
```

## Custom styling

Use `className` to customize the popup surface and `arrowClassName` to keep the arrow fill matched. Pair semantic surface, border, and foreground tokens so nested title, description, and action colors remain legible across color schemes.

```tsx
import { Button, Popover } from "@zentara-co/zenos-ui";

function PopoverCustomExample() {
  return (
    <Popover.Root>
      <Popover.Trigger render={<Button variant="primary" />}>Campaign summary</Popover.Trigger>
      <Popover.Content
        align="start"
        arrow
        className="border-border-accent-purple-default bg-background-accent-purple-subtlest-default"
        arrowClassName="text-background-accent-purple-subtlest-default"
      >
        <Popover.Header>
          <Popover.Title className="text-text-accent-purple-bolder">
            Quarterly campaign
          </Popover.Title>
          <Popover.Description className="text-text-accent-purple-bolder opacity-80">
            Three audiences and 24 published assets.
          </Popover.Description>
        </Popover.Header>
        <Popover.Footer>
          <Popover.Close className="border-border-accent-purple-default text-text-accent-purple-bolder hover:bg-background-accent-purple-subtlest-hover">
            Got it
          </Popover.Close>
        </Popover.Footer>
      </Popover.Content>
    </Popover.Root>
  );
}
```

## Popover or another component

Use Popover for compact, interactive content anchored to a trigger. Use [Tooltip](/components/tooltip/) for brief non-interactive descriptions, [Dropdown Menu](/components/dropdown-menu/) for a list of commands, and [Dialog](/components/dialog/) for modal or longer tasks.

## Anatomy

```text
Popover.Root
Popover.Trigger
Popover.Content
Popover.Header
Popover.Title
Popover.Description
Popover.Footer
Popover.Close
Popover.Arrow
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial uncontrolled state. |
| onOpenChange | (open: boolean, eventDetails) => void | — | Runs when visibility changes. |
| Trigger.render / Close.render | ReactElement \| function | — | Composes Trigger or Close with another element. |
| side | top \| right \| bottom \| left \| inline-* | bottom | Preferred popup side. |
| align | start \| center \| end | center | Position relative to trigger. |
| arrow | boolean | false | Renders the arrow inside Content. The arrow uses the same enter and exit motion as the popup. |
| Content.disableMotion | boolean | false | Disables the popup and arrow enter and exit animation for this instance. |
| sideOffset / alignOffset | number | sideOffset: 8 | Adjusts the popup distance and alignment-axis offset. |
| Close.variant / Close.size | ButtonVariant / sm \| md \| lg | outline / sm | Styles Popover.Close when it renders its default button. |
| Content.className / arrowClassName / positionerClassName | string | — | Customizes the popup, arrow, or positioning wrapper. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Title and Description name and describe the popup through Base UI’s ARIA relationships. The trigger receives expanded-state semantics. Escape and allowed outside interaction dismiss the popup, and focus returns to the trigger. Keep the focus order logical, label every form control, and avoid putting essential information in an unlabeled popup.

Source: https://zenos-ui.pages.dev/components/popover/