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.

32 linesCodeBlameRaw
1import { HoverCard as Primitive } from "radix-ui";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5
6// shadcn/ui's hover card, styled with g1t's tokens. It opens on hover and
7// keyboard focus, never on touch: a tap on its trigger does what the
8// trigger does. Hover hints (a label, nothing more) use the Tooltip.
9
10export function HoverCard({ openDelay = 450, closeDelay = 150, ...props }: ComponentProps<typeof Primitive.Root>) {
11 return <Primitive.Root openDelay={openDelay} closeDelay={closeDelay} {...props} />;
12}
13
14export const HoverCardTrigger = Primitive.Trigger;
15
16export function HoverCardContent({ className, align = "start", sideOffset = 6, ...props }: ComponentProps<typeof Primitive.Content>) {
17 return (
18 <Primitive.Portal>
19 <Primitive.Content
20 align={align}
21 sideOffset={sideOffset}
22 collisionPadding={12}
23 className={cn(
24 "z-50 w-80 max-w-[calc(100vw-2rem)] rounded-xl border border-line-strong bg-raised p-4 text-sm text-fg shadow-xl shadow-black/40 outline-none",
25 "origin-(--radix-hover-card-content-transform-origin) data-[state=open]:animate-pop-in data-[state=closed]:animate-pop-out motion-reduce:animate-none",
26 className,
27 )}
28 {...props}
29 />
30 </Primitive.Portal>
31 );
32}