Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Hover Card for React and Tailwind

Popover that appears on hover.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/hover-card.json

Anatomy

HoverCardArrow
└── HoverCardArrowTip
HoverCardTrigger
HoverCardContent
└── HoverCardPositioner

Usage

import { MapPinIcon } from "lucide-react";
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  HoverCard,
  HoverCardContent,
  HoverCardTrigger,
} from "@/components/ui/hover-card";
<HoverCard>
  <HoverCardTrigger asChild>
    <Button variant="link">Hover here</Button>
  </HoverCardTrigger>
  <HoverCardContent>
    <div className="flex gap-4">
      <Avatar>
        <AvatarImage src="https://github.com/vinihvc.png" />
        <AvatarFallback>VV</AvatarFallback>
      </Avatar>
      <div className="flex flex-col gap-2">
        <a
          className="font-medium text-sm underline underline-offset-4"
          href="https://github.com/vinihvc"
          rel="noopener"
          target="_blank"
        >
          @vinihvc
        </a>

        <p className="text-muted-foreground text-sm">Frontend Developer</p>

        <p className="flex items-center gap-1 text-muted-foreground text-xs">
          <MapPinIcon className="size-4" />
          Joined in 2016
        </p>
      </div>
    </div>
  </HoverCardContent>
</HoverCard>

Accessibility

KeyDescription
Enter
Activate the focused item.
Space
Activate the focused control.

Demos

Controlled

Disabled

Positioning

Triggers Delays

API Reference

HoverCard

PropType
AttributeType

HoverCardArrow

div

PropType
AttributeType
CSS variableType

HoverCardArrowTip

div

PropType
CSS variableType

HoverCardTrigger

button

PropType
AttributeType

HoverCardPositioner

div

PropType
CSS variableType

HoverCardContent

div

PropType
AttributeType
CSS variableType

useHoverCard