Components

Hover Card

The shadcn/ui Hover Card that grows out of its trigger with snappier delays and an optional arrow — plus two animated React hover card blocks built with Motion and Radix: a user profile preview that opens from the trigger, and a link preview that rises and follows the cursor.

  • Drop-in shadcn API
  • Radix positioning
  • Motion blocks
  • prefers-reduced-motion

Reviewed by @adakim and @leopark. Hover or focus a name to see their profile.

Installation

$ npx shadcn@latest add https://duskui.com/r/hover-card.json

Same exports as shadcn/ui (HoverCard, HoverCardTrigger, HoverCardContent) plus showArrow. It opens after 400ms and closes 200ms after the pointer leaves; pass openDelay / closeDelay to change that. Animations are CSS (tw-animate-css), so the base needs no Motion.

Usage

mention.tsx
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"

export function Mention() {
  return (
    <HoverCard>
      <HoverCardTrigger asChild>
        <a href="/u/duskui">@duskui</a>
      </HoverCardTrigger>
      <HoverCardContent className="w-80">
        Animated React components for shadcn/ui.
      </HoverCardContent>
    </HoverCard>
  )
}

Examples

Default

Scales and slides out of the trigger from Radix's transform origin, and closes quicker than it opened. showArrow draws a small arrow that blends into the border. Opens on hover and on keyboard focus of the trigger.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Profile Hover Card

A user preview for @mentions and avatars. It opens out of the trigger, then the avatar, name, bio, meta and stats fade up in sequence. The avatar is a plain <img> layered over the user's initials, so a missing or broken image still looks intentional (hover @leopark). Put a Follow button in action.

Reviewed by @adakim and @leopark. Hover or focus a name to see their profile.

$ npx shadcn@latest add https://duskui.com/r/profile-hover-card.json
PropTypeDefaultDescription
userProfileUser—{ name, handle?, avatarUrl?, bio?, location?, joined?, verified?, stats?, cover? }. Required.
childrenReactElement—The trigger, usually a link to the profile. Required.
actionReactNode—Top-right buttons, e.g. Follow.
open / defaultOpen / onOpenChangeboolean / boolean / (open: boolean) => void—Controlled or uncontrolled state.
openDelay / closeDelaynumber400 / 200Hover delays in ms.
side / align / sideOffsetRadix content props"bottom" / "start" / 8Placement next to the trigger.

An inline link that previews its destination. The card rises out of the link, then leans toward the cursor as it moves along the text. The image shimmers with the DuskUI Skeleton until it loads, then fades in; with no image (or a broken one) it shows a plain panel with the site's initial. Pass Open Graph data you fetched on the server as preview.

DuskUI builds on shadcn/ui and animates everything with Motion. Move your cursor along a link and the card follows.

$ npx shadcn@latest add https://duskui.com/r/link-preview.json
PropTypeDefaultDescription
hrefstring—Link destination. Required.
childrenReactNode—The link text. Required.
preview{ title, description?, image?, siteName? }—What the card shows. siteName defaults to the hostname. Required.
side"top" | "bottom""top"Which side of the link the card opens on.
followCursorbooleantrueLean toward the cursor along the link.
open / onOpenChangeboolean / (open: boolean) => void—Controlled state.
openDelay / closeDelaynumber300 / 200Hover delays in ms.
contentClassNamestring—Classes for the card.

API Reference

Same parts as shadcn/ui: HoverCard, HoverCardTrigger and HoverCardContent. Each forwards the Radix Hover Card props.

PropTypeDefaultDescription
openDelay / closeDelaynumber400 / 200Hover delays in ms (on HoverCard).
open / onOpenChangeboolean / (open: boolean) => void—Controlled state (on HoverCard).
side / align / sideOffsetRadix content props"bottom" / "center" / 6Placement (on HoverCardContent).
showArrowbooleanfalseDraw an arrow pointing at the trigger (on HoverCardContent).

Accessibility

  • A hover card is a visual extra: screen readers don't announce it, so the trigger itself must make sense on its own (a real link with clear text).
  • It also opens when the trigger gets keyboard focus and closes on Escape or blur, so keyboard users get the same preview.
  • Don't put actions that exist only inside the card; the Follow button in the demo is a convenience, not the only way to follow.
  • Under prefers-reduced-motion the cards only fade: no scale, stagger or cursor following.