Tooltip
fluid-functionalism/tooltipFreeComponent
Floating tooltip with spring-based animations, configurable placement, and rich content support.
Install it
npx shadcn@latest add https://fluidfunctionalism.com/r/tooltip.jsonSource
1"use client";23import {4 createContext,5 useContext,6 useEffect,7 useState,8 type ReactNode,9} from "react";10import * as TooltipPrimitive from "@radix-ui/react-tooltip";11import { motion } from "framer-motion";12import { cn } from "@/lib/utils";13import { spring, exitFallbackMs } from "@/lib/springs";14import { fontWeights } from "@/lib/font-weight";15import { useShape } from "@/lib/shape-context";1617// ---------------------------------------------------------------------------18// Portal container context19// ---------------------------------------------------------------------------2021const TooltipPortalContainerContext = createContext<HTMLElement | null>(null);2223function TooltipPortalContainer({24 value,25 children,26}: {27 value: HTMLElement | null;28 children: ReactNode;29}) {30 return (31 <TooltipPortalContainerContext.Provider value={value}>32 {children}33 </TooltipPortalContainerContext.Provider>34 );35}3637// ---------------------------------------------------------------------------38// Provider39// ---------------------------------------------------------------------------4041const DEFAULT_DELAY = 200;4243// Tracks whether an app-level <TooltipProvider> is above us. Each Tooltip44// only wraps itself in a local primitive Provider when there isn't one —45// a per-instance Provider would defeat cross-tooltip skip-delay grouping46// (moving between adjacent tooltips would re-wait the full delay). Radix's47// Root throws without a Provider, so the local fallback can't be dropped.48const TooltipGroupContext = createContext(false);4950interface TooltipProviderProps {51 children: ReactNode;52 /** Hover delay before tooltips open, in ms. Defaults to 200. */53 delayDuration?: number;54 /** After a tooltip closes, adjacent tooltips opened within this window55 * skip the hover delay, in ms. Defaults to 300. */56 skipDelayDuration?: number;57}5859/** Groups descendant Tooltips so that once one opens, moving to an adjacent60 * trigger shows its tooltip instantly instead of re-waiting the full delay.61 * Wrap once at the app (or section) level; bare Tooltips still work without62 * it via a per-instance fallback. */63function TooltipProvider({64 children,65 delayDuration = DEFAULT_DELAY,66 skipDelayDuration = 300,67}: TooltipProviderProps) {68 return (69 <TooltipGroupContext.Provider value={true}>70 <TooltipPrimitive.Provider71 delayDuration={delayDuration}72 skipDelayDuration={skipDelayDuration}73 >74 {children}75// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fluid-functionalism
All 53 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | fluid-functionalism | Components | Free | 3 deps | |
| Accordion (Base UI)accordion-base | fluid-functionalism | Components | Free | 3 deps | |
| Ask User Questionsask-user-questions | fluid-functionalism | Components | Free | 2 deps | |
| Badgebadge | fluid-functionalism | Components | Free | 1 dep | |
| Buttonbutton | fluid-functionalism | Components | Free | 4 deps | |
| Button (Base UI)button-base | fluid-functionalism | Components | Free | 4 deps | |
| Cardcard | fluid-functionalism | Components | Free | 1 dep | |
| Chat Messagechat-message | fluid-functionalism | Components | Free | 1 dep |
