Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

42 linesCodeBlameRaw
1import { Tooltip as Primitive } from "radix-ui";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5
6// shadcn/ui's tooltip, styled with g1t's tokens: the inverted bubble, the
7// page's foreground behind the page's background colour, so it reads at a
8// glance in either theme. Each tooltip carries its own provider, so one
9// can be dropped in anywhere without setup.
10
11export function TooltipProvider({ delayDuration = 200, ...props }: ComponentProps<typeof Primitive.Provider>) {
12 return <Primitive.Provider delayDuration={delayDuration} {...props} />;
13}
14
15export function Tooltip(props: ComponentProps<typeof Primitive.Root>) {
16 return (
17 <TooltipProvider>
18 <Primitive.Root {...props} />
19 </TooltipProvider>
20 );
21}
22
23export const TooltipTrigger = Primitive.Trigger;
24
25export function TooltipContent({ className, sideOffset = 6, children, ...props }: ComponentProps<typeof Primitive.Content>) {
26 return (
27 <Primitive.Portal>
28 <Primitive.Content
29 sideOffset={sideOffset}
30 className={cn(
31 "z-50 max-w-xs rounded-md bg-fg px-3 py-1.5 text-xs font-medium text-bg shadow-md text-balance",
32 "origin-(--radix-tooltip-content-transform-origin) animate-pop-in data-[state=closed]:animate-pop-out motion-reduce:animate-none",
33 className,
34 )}
35 {...props}
36 >
37 {children}
38 <Primitive.Arrow className="fill-fg" width={10} height={5} />
39 </Primitive.Content>
40 </Primitive.Portal>
41 );
42}