VC
@nextjs
The React Framework – created and maintained by @vercel.
Joined December 2021
Component
hover-card-demo
not found in registry.
import { CalendarDays } from "lucide-react"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import {
HoverCard,
HoverCardArrow,
HoverCardContent,
HoverCardTrigger,
} from "@/components/ui/hover-card"
export default function HoverCardDemo() {
return (
<HoverCard>
<HoverCardTrigger asChild>
<Button variant="link">@nextjs</Button>
</HoverCardTrigger>
<HoverCardContent className="w-80">
<HoverCardArrow />
<div className="flex justify-between space-x-4">
<Avatar>
<AvatarImage src="https://github.com/vercel.png" />
<AvatarFallback>VC</AvatarFallback>
</Avatar>
<div className="space-y-1">
<h4 className="font-semibold text-sm">@nextjs</h4>
<p className="text-sm">
The React Framework – created and maintained by @vercel.
</p>
<div className="flex items-center pt-2">
<CalendarDays className="mr-2 h-4 w-4 opacity-70" />{" "}
<span className="text-muted-foreground text-xs">
Joined December 2021
</span>
</div>
</div>
</div>
</HoverCardContent>
</HoverCard>
)
}
Not found
Installation
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { HoverCard as HoverCardPrimitive } from "@ark-ui/react/hover-card"
import { Portal } from "@ark-ui/react/portal"
import { cn } from "@/lib/utils"
const HoverCard = HoverCardPrimitive.Root
const HoverCardTrigger = HoverCardPrimitive.Trigger
const HoverCardArrow = React.forwardRef<
React.ElementRef<typeof HoverCardPrimitive.Arrow>,
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Arrow>
>(({ className, ...props }, ref) => (
<HoverCardPrimitive.Arrow>
<HoverCardPrimitive.ArrowTip
ref={ref}
className={cn("border-t-[1px] border-l-[1px]", className)}
{...props}
/>
</HoverCardPrimitive.Arrow>
))
HoverCardArrow.displayName = "HoverCardArrow"
const HoverCardContent = React.forwardRef<
React.ElementRef<typeof HoverCardPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
>(({ className, ...props }, ref) => (
<Portal>
<HoverCardPrimitive.Positioner>
<HoverCardPrimitive.Content
ref={ref}
className={cn(
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
className
)}
{...props}
/>
</HoverCardPrimitive.Positioner>
</Portal>
))
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
export { HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger }
Not Found
Update the import paths to match your project setup.
Usage
import {
HoverCard,
HoverCardArrow,
HoverCardContent,
HoverCardTrigger,
} from "@/components/ui/hover-card"
<HoverCard>
<HoverCardTrigger>Hover</HoverCardTrigger>
<HoverCardContent>
<HoverCardArrow />
Content
</HoverCardContent>
</HoverCard>