Built and maintained by @michael
Installation
$ pnpm dlx shadcn@latest add @synccn/hover-cardFirst time in this project? Connect synccn with one command.
Usage
import { HoverCard } from "@/components/ui/hover-card";<HoverCard trigger={<a>@michael</a>}>…</HoverCard>API reference
Generated from the component's TypeScript types, so it always matches the code.
HoverCard
Rich preview that appears when the pointer rests on (or keyboard focuses) the trigger.
PropTypeDescription
- triggerrequired
React.ReactNodeElement that opens the card.
- openDelay
numberDefault
300Milliseconds before opening.
- closeDelay
numberDefault
150Milliseconds before closing.
- side
"top" | "bottom"Default
"bottom"Where the card appears.
- children
React.ReactNodeContent to render.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
Accessibility
- Opens on hover and focus. Keep its content a preview; the link it's attached to should still work on its own.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: dialog
More overlays
DialogModal with focus trap, scroll lock and Escape to close.SheetPanel that slides in from the left, right or bottom.Dropdown MenuActions, checkboxes, labels and shortcuts with arrow-key navigation.Context MenuRight-click menu that also opens on long-press.PopoverFloating panel anchored to a trigger.TooltipLabel on hover and focus, on any side.