# Preview

An anchored rich preview displayed from a link or trigger.

An anchored rich preview displayed from a link or trigger.

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

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

function PreviewExample() {
  return (
    <Stack gap="2" align="center">
      <Text size="s" color="subtle">
        Hover or focus the link
      </Text>
      <Preview.Root>
        <Preview.Trigger href="#preview-api">Workspace</Preview.Trigger>
        <Preview.Content>
          <Preview.Header>
            <Preview.Title>Design workspace</Preview.Title>
            <Preview.Description>Shared components and product foundations.</Preview.Description>
          </Preview.Header>
        </Preview.Content>
      </Preview.Root>
    </Stack>
  );
}
```

Hover the trigger with a pointer or move keyboard focus to it. Preview supplements a destination
link; activating the link still follows its native `href`. Use Popover when clicking the trigger
should open interactive content instead.

## Import

```tsx
import { Preview } from "@zentara-co/zenos-ui";
```

Preview adds supplementary information to a destination link on hover or focus. The trigger remains a native anchor, so navigation works even when the preview never opens.

`Preview.Trigger` defaults to `delay={0}` and `closeDelay={0}` so the card and arrow follow the pointer and focus immediately. Increase `delay` when a short hover grace period helps avoid accidental previews; the popup and arrow still fade in and out together over 150ms.

## Anatomy

`Content` supplies the portal, collision-aware positioner, popup, and arrow. Group the title and description with `Header` for consistent spacing.

```tsx
<Preview.Root>
  <Preview.Trigger href="/workspace">Workspace</Preview.Trigger>
  <Preview.Content>
    <Preview.Header>
      <Preview.Title>Design workspace</Preview.Title>
      <Preview.Description>Shared components and product foundations.</Preview.Description>
    </Preview.Header>
  </Preview.Content>
</Preview.Root>
```

## Rich preview

Keep content concise and descriptive. Users should be able to decide whether to follow the destination without interacting with the preview itself.

```tsx
import { Preview } from "@zentara-co/zenos-ui";

function PreviewRichExample() {
  return (
    <Preview.Root>
      <Preview.Trigger href="#preview-api" delay={200}>
        Security workspace
      </Preview.Trigger>
      <Preview.Content side="bottom" align="start">
        <div className="mb-3 grid h-24 place-items-center rounded-md bg-background-neutral-subtle text-sm text-text-subtle">
          Workspace preview
        </div>
        <Preview.Header>
          <Preview.Title>Security workspace</Preview.Title>
          <Preview.Description>
            24 members · 18 active findings · Updated five minutes ago
          </Preview.Description>
        </Preview.Header>
      </Preview.Content>
    </Preview.Root>
  );
}
```

## Placement

Content defaults below and centered on the trigger. Choose another side or alignment when surrounding layout requires it; collision avoidance can still flip the final placement.

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

function PreviewPlacementExample() {
  return (
    <Stack direction="row" gap="6" align="center" wrap="wrap" justify="center">
      <Preview.Root>
        <Preview.Trigger href="#preview-api" delay={0} closeDelay={0}>
          Top start
        </Preview.Trigger>
        <Preview.Content side="top" align="start">
          <Preview.Header>
            <Preview.Title>Top preview</Preview.Title>
            <Preview.Description>Aligned to the start of its link.</Preview.Description>
          </Preview.Header>
        </Preview.Content>
      </Preview.Root>
      <Preview.Root>
        <Preview.Trigger href="#preview-api" delay={0} closeDelay={0}>
          Bottom center
        </Preview.Trigger>
        <Preview.Content side="bottom" align="center">
          <Preview.Header>
            <Preview.Title>Bottom preview</Preview.Title>
            <Preview.Description>Centered beneath its link.</Preview.Description>
          </Preview.Header>
        </Preview.Content>
      </Preview.Root>
      <Preview.Root>
        <Preview.Trigger href="#preview-api" delay={0} closeDelay={0}>
          Right without arrow
        </Preview.Trigger>
        <Preview.Content side="right" align="end" arrow={false}>
          <Preview.Header>
            <Preview.Title>Right preview</Preview.Title>
            <Preview.Description>Aligned to the end without an arrow.</Preview.Description>
          </Preview.Header>
        </Preview.Content>
      </Preview.Root>
    </Stack>
  );
}
```

## Controlled state

Use controlled state when another part of the surrounding interface needs to observe preview visibility. Hover and focus still request changes through `onOpenChange`.

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

function PreviewControlledExample() {
  const [open, setOpen] = useState(false);
  return (
    <Stack gap="3" align="center">
      <Preview.Root open={open} onOpenChange={setOpen}>
        <Preview.Trigger href="#preview-api" delay={0} closeDelay={0}>
          Workspace activity
        </Preview.Trigger>
        <Preview.Content>
          <Preview.Header>
            <Preview.Title>Workspace activity</Preview.Title>
            <Preview.Description>Seven changes since your last visit.</Preview.Description>
          </Preview.Header>
        </Preview.Content>
      </Preview.Root>
      <Text size="s" color="subtle">
        Preview is {open ? "open" : "closed"}.
      </Text>
    </Stack>
  );
}
```

## Motion

Previews 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 surface.

Hover or focus each link. The first preview animates in and out. `disableMotion` makes the second appear and disappear immediately.

```tsx
import { Grid, Preview, Stack, Text } from "@zentara-co/zenos-ui";

function PreviewMotionExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      <Stack gap="2" align="center">
        <Text size="s" color="subtle">
          With motion
        </Text>
        <Preview.Root>
          <Preview.Trigger href="#preview-motion">Workspace</Preview.Trigger>
          <Preview.Content>
            <Preview.Header>
              <Preview.Title>Design workspace</Preview.Title>
              <Preview.Description>Shared components and product foundations.</Preview.Description>
            </Preview.Header>
          </Preview.Content>
        </Preview.Root>
      </Stack>
      <Stack gap="2" align="center">
        <Text size="s" color="subtle">
          Without motion
        </Text>
        <Preview.Root>
          <Preview.Trigger href="#preview-motion-static">Workspace</Preview.Trigger>
          <Preview.Content disableMotion>
            <Preview.Header>
              <Preview.Title>Design workspace</Preview.Title>
              <Preview.Description>Shared components and product foundations.</Preview.Description>
            </Preview.Header>
          </Preview.Content>
        </Preview.Root>
      </Stack>
    </Grid>
  );
}
```

## Custom styling

Use the same semantic surface, border, and foreground family across `className`, `arrowClassName`, Title, and Description. `Preview.Trigger` accepts the Link component’s `variant`, `underline`, and `size` treatments.

```tsx
import { Preview } from "@zentara-co/zenos-ui";

function PreviewCustomExample() {
  return (
    <Preview.Root>
      <Preview.Trigger href="#preview-api" variant="subtle" underline="always">
        Quarterly report
      </Preview.Trigger>
      <Preview.Content
        align="start"
        className="border-border-accent-purple-default bg-background-accent-purple-subtlest-default"
        arrowClassName="text-background-accent-purple-subtlest-default [--border-default:var(--border-accent-purple-default)]"
      >
        <Preview.Header>
          <Preview.Title className="text-text-accent-purple-bolder">Quarterly report</Preview.Title>
          <Preview.Description className="text-text-accent-purple-bolder opacity-80">
            Revenue, adoption, and retention highlights from the latest quarter.
          </Preview.Description>
        </Preview.Header>
      </Preview.Content>
    </Preview.Root>
  );
}
```

## Preview or another component

Use Preview to supplement a destination link with concise, non-essential information. Use [Tooltip](/components/tooltip/) for a short label, [Popover](/components/popover/) for interactive controls, and [Dialog](/components/dialog/) for modal or longer tasks.

## Anatomy

```text
Preview.Root
Preview.Trigger
Preview.Content
Preview.Header
Preview.Title
Preview.Description
Preview.Arrow
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| open | boolean | — | Controlled preview state. |
| defaultOpen | boolean | false | Initial uncontrolled state. |
| onOpenChange | (open: boolean, eventDetails) => void | — | Runs when hover or focus changes visibility. |
| delay / closeDelay | number | 0 / 0 | Milliseconds before the preview opens or closes after hover or focus changes. Set on Preview.Trigger. |
| side | top \| right \| bottom \| left | bottom | Preferred placement. |
| align | start \| center \| end | center | Trigger alignment. |
| arrow | boolean | true | Renders the popup arrow with the same enter and exit motion as the surface. |
| 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. |
| Trigger.variant / Trigger.underline / Trigger.size | LinkVariant / LinkUnderline / sm \| md \| lg | default / hover / md | Applies the Link component's visual treatments to the native anchor trigger. |
| 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

Preview opens from both pointer hover and keyboard focus, and the trigger keeps native link behavior. Escape dismisses the preview. Treat its content as supplementary: essential labels, status, or instructions must remain available in the page itself. Use Popover when users need interactive controls, and provide meaningful destination text on every Preview.Trigger.

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