8.7k

Tooltip

A popup that appears when an element is hovered or focused, showing a hint for sighted users.

API Reference

Installation

pnpm dlx shadcn@latest add @coss/tooltip

Usage

import {
  Tooltip,
  TooltipCreateHandle,
  TooltipPopup,
  TooltipProvider,
  TooltipTrigger,
} from "@/components/ui/tooltip"
<Tooltip>
  <TooltipTrigger render={<Button variant="outline" />}>
    Hover me
  </TooltipTrigger>
  <TooltipPopup>Helpful hint</TooltipPopup>
</Tooltip>

Examples

Grouped Tooltips

To group multiple tooltips so they appear instantly after the first one is opened, wrap them in TooltipProvider. The grouping logic ensures that once a tooltip becomes visible, the adjacent tooltips will be shown instantly.

Animated Tooltips

You can create animated tooltips that smoothly transition between different triggers using detached triggers. This pattern allows multiple triggers to share a single tooltip popup, with automatic animations for position, size, and content changes.

To create detached triggers:

  1. Create a handle using TooltipCreateHandle
  2. Attach the same handle to multiple TooltipTrigger components
  3. Each trigger provides a payload prop containing the content component
  4. Use a single Tooltip component with the handle to render the popup

Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with coss ui quickly.

Quick Checklist

  • Replace asChildrender on TooltipTrigger
  • Prefer TooltipPopup; TooltipContent remains for legacy
  • If you used asChild on parts, switch to the render prop

Comparison Example

shadcn/ui
<Tooltip>
  <TooltipTrigger asChild>
    <Button variant="outline">Hover me</Button>
  </TooltipTrigger>
  <TooltipContent>Helpful hint</TooltipContent>
</Tooltip>
coss ui
<Tooltip>
  <TooltipTrigger render={<Button variant="outline" />}>
    Hover me
  </TooltipTrigger>
  <TooltipPopup>Helpful hint</TooltipPopup>
</Tooltip>

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).