VibeUI
ComponentsDocs
VibeUI

Components with taste, that you own. Copy the source, retint the tokens, keep every line.

Library

  • All components
  • Signature pieces
  • Text effects
  • Footers

Docs

  • Introduction
  • Installation
  • Theming
  • CLI

Project

  • GitHub
  • Agents and MCP
  • Issues
  • MIT license
© 2026 VibeUI · MIT licensed
  1. Components
  2. Overlays
  3. Tooltip

Tooltip

Hover and focus tooltip: pure CSS, short open delay, scales and slides in.

OverlaysClient component
Top (default)Appears belowCopy token path

Install

bash
npx @agents-npm-packages/vibeui add tooltip --dir ./src/components/ui

Import

tsx
import { Tooltip } from "@/components/ui/tooltip"

API

Generated from the component's TypeScript types, so it always matches the source. * marks a required prop.

<Tooltip>

PropTypeDefaultDescription
content*ReactNode—Tooltip content.
children*ReactNode—Content rendered inside the component.
side"left" | "right" | "top" | "bottom""top"Which edge or side to anchor to.
classNamestring—Extra classes, merged with the component's own.

Source

src/components/ui/tooltip.tsx
"use client";

import * as React from "react";
import { cn } from "@/lib/utils";

const placement = {
  top: "bottom-[calc(100%+8px)] left-1/2 -translate-x-1/2 origin-bottom translate-y-1 group-hover/tip:translate-y-0 group-focus-within/tip:translate-y-0",
  bottom:
    "top-[calc(100%+8px)] left-1/2 -translate-x-1/2 origin-top -translate-y-1 group-hover/tip:translate-y-0 group-focus-within/tip:translate-y-0",
  left: "right-[calc(100%+8px)] top-1/2 -translate-y-1/2 origin-right translate-x-1 group-hover/tip:translate-x-0 group-focus-within/tip:translate-x-0",
  right:
    "left-[calc(100%+8px)] top-1/2 -translate-y-1/2 origin-left -translate-x-1 group-hover/tip:translate-x-0 group-focus-within/tip:translate-x-0",
} as const;

/** Hover and focus tooltip: pure CSS, short open delay, scales and slides in. */
export function Tooltip({
  content,
  children,
  side = "top",
  className,
}: {
  content: React.ReactNode;
  children: React.ReactNode;
  side?: keyof typeof placement;
  className?: string;
}) {
  const id = React.useId();

  return (
    <span aria-describedby={id} className={cn("group/tip relative inline-flex", className)}>
      {children}
      <span
        id={id}
        role="tooltip"
        className={cn(
          "pointer-events-none absolute z-30 w-max max-w-[220px] scale-95 rounded-[7px] bg-ink px-2.5 py-1.5 text-[12px] font-medium leading-snug text-surface opacity-0 shadow-lift transition-[opacity,transform] duration-200 ease-out group-hover/tip:scale-100 group-hover/tip:opacity-100 group-hover/tip:delay-300 group-focus-within/tip:scale-100 group-focus-within/tip:opacity-100",
          placement[side],
        )}
      >
        {content}
      </span>
    </span>
  );
}

Exports Tooltip. Peer dependencies: clsx, tailwind-merge.

PreviousToastNextTour