# Tooltip

Supplemental text for pointer and keyboard users.

Supplemental text for pointer and keyboard users.

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

```tsx
import { CopyIcon } from "@phosphor-icons/react";
import { Button, Stack, Tooltip } from "@zentara-co/zenos-ui";

function TooltipVariantsExample() {
  return (
    <Stack direction="row" gap="6">
      <Tooltip.Provider>
        {(["default", "solid"] as const).map((variant) => (
          <Tooltip.Root key={variant}>
            <Tooltip.Trigger render={<Button variant="primary" startIcon={<CopyIcon />} />}>
              {variant}
            </Tooltip.Trigger>
            <Tooltip.Content variant={variant}>{variant} tooltip</Tooltip.Content>
          </Tooltip.Root>
        ))}
      </Tooltip.Provider>
    </Stack>
  );
}
```

## Import

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

## Variants

`default` uses the brand-subtle surface for short labels. `solid` provides a stronger overlay surface for slightly longer supplemental descriptions.

## Placement

Set the preferred `side` and alignment on `Tooltip.Content`. Base UI flips or shifts the popup when collision avoidance requires it.

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

function TooltipPlacementExample() {
  const sides = ["top", "right", "bottom", "left"] as const;

  return (
    <Tooltip.Provider delay={100}>
      <Stack direction="row" gap="5" wrap="wrap" justify="center">
        {sides.map((side) => (
          <Tooltip.Root key={side}>
            <Tooltip.Trigger render={<Button variant="primary" />}>{side}</Tooltip.Trigger>
            <Tooltip.Content side={side}>Placed on the {side}</Tooltip.Content>
          </Tooltip.Root>
        ))}
      </Stack>
    </Tooltip.Provider>
  );
}
```

## Controlled state

Use `open` with `onOpenChange` when another part of the interface must observe visibility. Hover, focus, Escape, and outside interaction all report through the same callback.

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

function TooltipControlledExample() {
  const [open, setOpen] = useState(false);

  return (
    <Stack gap="3" align="start">
      <Tooltip.Provider delay={0}>
        <Tooltip.Root open={open} onOpenChange={setOpen}>
          <Tooltip.Trigger render={<Button variant="primary" />}>Policy status</Tooltip.Trigger>
          <Tooltip.Content variant="solid" side="bottom" align="start">
            Last checked five minutes ago.
          </Tooltip.Content>
        </Tooltip.Root>
      </Tooltip.Provider>
      <Text size="s" color="subtle" aria-live="polite">
        Tooltip is {open ? "open" : "closed"}.
      </Text>
    </Stack>
  );
}
```

## Motion

Tooltips 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 tooltip.

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

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

function TooltipMotionExample() {
  return (
    <Tooltip.Provider delay={0}>
      <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
        <Stack align="center">
          <Tooltip.Root>
            <Tooltip.Trigger render={<Button variant="primary" />}>With motion</Tooltip.Trigger>
            <Tooltip.Content>Saved two minutes ago</Tooltip.Content>
          </Tooltip.Root>
        </Stack>
        <Stack align="center">
          <Tooltip.Root>
            <Tooltip.Trigger render={<Button variant="primary" />}>Without motion</Tooltip.Trigger>
            <Tooltip.Content disableMotion>Saved two minutes ago</Tooltip.Content>
          </Tooltip.Root>
        </Stack>
      </Grid>
    </Tooltip.Provider>
  );
}
```

## Provider delay

Wrap related tooltips in one Provider to share `delay`, `closeDelay`, and the grace `timeout`. Once one tooltip appears, nearby tooltips can open instantly during the grace period. Zenos defaults `delay` to zero; set a modest delay for dense toolbars when immediate hover feedback feels noisy.

## Arrow

Content includes a matching arrow by default. Disable it for surfaces where trigger direction is already clear.

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

function TooltipArrowExample() {
  return (
    <Tooltip.Provider delay={0}>
      <Stack direction="row" gap="4" wrap="wrap">
        <Tooltip.Root>
          <Tooltip.Trigger render={<Button variant="primary" />}>With arrow</Tooltip.Trigger>
          <Tooltip.Content>Arrow points to the trigger</Tooltip.Content>
        </Tooltip.Root>
        <Tooltip.Root>
          <Tooltip.Trigger render={<Button variant="primary" />}>Without arrow</Tooltip.Trigger>
          <Tooltip.Content showArrow={false} variant="solid">
            No arrow is rendered
          </Tooltip.Content>
        </Tooltip.Root>
      </Stack>
    </Tooltip.Provider>
  );
}
```

Tooltips supplement an accessible name; they should not contain essential instructions or interactive content.

## Variants

default, solid

## Anatomy

```text
Tooltip.Provider
Tooltip.Root
Tooltip.Trigger
Tooltip.Content
Tooltip.Arrow
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| delay | number | 0 | Provider or trigger opening delay. |
| Provider.closeDelay / timeout | number / number | 0 / 400 | Close delay and instant-open grace period for grouped tooltips. |
| open / defaultOpen | boolean | — | Controlled or initial tooltip visibility. |
| onOpenChange | (open: boolean, eventDetails) => void | — | Runs when visibility changes. |
| variant | default \| solid | default | Popup surface style. |
| side | top \| right \| bottom \| left | top | Preferred popup side. |
| align / sideOffset | start \| center \| end / number | center / 4 | Popup alignment and distance from the trigger. |
| showArrow | boolean | true | Renders a matching arrow that fades with the tooltip. |
| Content.disableMotion | boolean | false | Disables the popup and arrow enter and exit animation for this instance. |
| render | ReactElement \| function | — | Composes the trigger with another element. |
| native props | React.Base UI Tooltip props | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

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

## Accessibility

Tooltips open on pointer hover and keyboard focus, close with Escape, and connect to their trigger through Base UI's description relationship. Trigger composition uses `render`, so the rendered control must retain supplied props and refs. Keep tooltip content brief and non-interactive. Disabled native buttons cannot receive focus or hover events reliably; place essential explanations in persistent text rather than depending on a tooltip.

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