Overlays

Tooltip

Dark 12 Medium bubble, radius 8, raised shadow. One line, no arrow.

react-aria-components

Preview

Installation

Components are copied into your project — no runtime package.

  1. Install the following dependencies:

    terminal
    npm install react-aria-components
  2. Create a tooltip.tsx file and paste the following code into it.

    src/components/ui/tooltip.tsx
    "use client";
    
    import type { ReactNode } from "react";
    import { Tooltip as AriaTooltip, TooltipTrigger, type TooltipProps as AriaTooltipProps } from "react-aria-components";
    import { cx } from "@/utils/cx";
    
    export { TooltipTrigger };
    
    /** Dark 12 Medium bubble, radius 8, raised shadow. One line, no arrow. */
    export function Tooltip({ className, children, ...props }: Omit<AriaTooltipProps, "className" | "children"> & { className?: string; children: ReactNode }) {
      return (
        <AriaTooltip
          offset={6}
          {...props}
          className={cx(
            "rounded-sm bg-inverse px-2 py-1.5 text-sm font-medium text-fg-inverse shadow-[0_4px_12px_rgb(0_0_0/0.16)]",
            className,
          )}
        >
          {children}
        </AriaTooltip>
      );
    }
  3. Add the theme tokens and the cx helper from Installation if you haven’t yet, then update the import paths to match your project setup.