---
layout: ~/layouts/MdxDocLayout.astro
title: "Tooltip"
description: "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it."
sourceFile: "components/tooltip"
baseUIComponent: "tooltip"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import CodeBlock from "~/components/docs/CodeBlock.astro";
import Heading from "~/components/docs/Heading.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import {
  TooltipHeroDemo,
  TooltipBasicDemo,
  TooltipMultipleDemo,
} from "~/components/demos/TooltipDemo";

<ComponentSection>
  <ComponentExample
    code={`<Tooltip content="Add new item" asChild>
  <Button shape="square" icon={PlusIcon} />
</Tooltip>`}
  >
    <TooltipHeroDemo client:load />
  </ComponentExample>
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>
  <CodeBlock
    code={`import { Tooltip, TooltipProvider } from "@cloudflare/kumo";`}
    lang="tsx"
  />
  <Heading level={3}>Granular</Heading>
  <CodeBlock
    code={`import { Tooltip, TooltipProvider } from "@cloudflare/kumo/components/tooltip";`}
    lang="tsx"
  />
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Usage</Heading>
  <CodeBlock code={`import { Tooltip, Button } from "@cloudflare/kumo";

export default function Example() {
  return (
    <Tooltip content="Tooltip text" asChild>
      <Button>Hover me</Button>
    </Tooltip>
  );
}`} lang="tsx" />
  For delay grouping across multiple tooltips, see [TooltipProvider](#tooltipprovider).
</ComponentSection>

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Basic Tooltip</Heading>
<ComponentExample
  code={`<Tooltip content="Add" asChild>
  <Button shape="square" icon={PlusIcon} />
</Tooltip>`}
>
  <TooltipBasicDemo client:load />
</ComponentExample>

  <Heading level={3}>Multiple Tooltips</Heading>
  <ComponentExample code={`<TooltipProvider>
  <div className="flex gap-2">
    <Tooltip content="Add" asChild>
      <Button shape="square" icon={PlusIcon} />
    </Tooltip>
    <Tooltip content="Change language" asChild>
      <Button shape="square" icon={TranslateIcon} />
    </Tooltip>
  </div>
</TooltipProvider>`}>
    <TooltipMultipleDemo client:load />
  </ComponentExample>
</ComponentSection>

<ComponentSection>
  <Heading level={2} id="tooltipprovider">TooltipProvider</Heading>

`TooltipProvider` groups multiple tooltips so that after the first tooltip has been shown, switching to another skips the open delay. Place it once at your app root or layout — not around each individual `Tooltip`.

  <CodeBlock code={`// Wrap your app or layout once
<TooltipProvider>
  <App />
</TooltipProvider>

// Then use Tooltip anywhere inside

<Tooltip content="Add" asChild>
  <Button shape="square" icon={PlusIcon} />
</Tooltip>`} lang="tsx" />
</ComponentSection>

<ComponentSection>
  <Heading level={2}>API Reference</Heading>
  <PropsTable component="Tooltip" />
</ComponentSection>
