Back to Base UIYou are on Hover Card.

Hover Card

A preview card that opens from its trigger after a deliberate hover.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks

Libraries

Base UI

Motion

Spring + short tween

Reduced motion

Fade in place
hover-card.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/hover-card.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/hover-card.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
hover-card.tsx
"use client";

import * as React from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

export type HoverCardProps = {
  trigger?: React.ReactNode;
  title?: string;
  description?: string;
  children?: React.ReactNode;
};

const pop = { type: "spring", stiffness: 400, damping: 31 } as const;

export function HoverCard({
  trigger = "@prequelui",
  title = "PrequelUI Animate",
  description = "Animated primitives for interfaces that already have a design system.",
  children,
}: HoverCardProps) {
  const [open, setOpen] = React.useState(false);
  const reduce = useReducedMotion();
  const enter = React.useRef<number | undefined>(undefined);
  const leave = React.useRef<number | undefined>(undefined);

  const show = () => {
    window.clearTimeout(leave.current);
    enter.current = window.setTimeout(() => setOpen(true), 200);
  };
  const hide = () => {
    window.clearTimeout(enter.current);
    leave.current = window.setTimeout(() => setOpen(false), 150);
  };

  React.useEffect(
    () => () => {
      window.clearTimeout(enter.current);
      window.clearTimeout(leave.current);
    },
    [],
  );

  return (
    <span className="relative inline-block" onPointerEnter={show} onPointerLeave={hide} onFocus={show} onBlur={hide}>
      <button type="button" className="text-[13px] font-medium underline decoration-border underline-offset-4">
        {trigger}
      </button>
      <AnimatePresence>
        {open && (
          <motion.div
            initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.95, y: 4, filter: "blur(2px)" }}
            animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1, y: 0, filter: "blur(0px)" }}
            exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.97, y: 2, filter: "blur(1px)" }}
            transition={reduce ? { duration: 0.2 } : pop}
            className="absolute left-0 top-full z-40 mt-2 w-64 rounded-xl border bg-background p-4 shadow-xl"
          >
            <p className="text-[13px] font-medium">{title}</p>
            <p className="mt-1 text-[13px] leading-6 text-muted-foreground">{description}</p>
            {children}
          </motion.div>
        )}
      </AnimatePresence>
    </span>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/hover-card.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

hover-card.tsx
import { HoverCard } from "@/components/prequelui/hover-card";

export default function Demo() {
  return (
    <HoverCard>
      {/* compose the parts exactly like the underlying primitive */}
    </HoverCard>
  );
}
import { HoverCard } from "@/components/prequelui/hover-card";

export function Variant() {
  return (
    <HoverCard tempo={1.2}>
      …
    </HoverCard>
  );
}
03

Animation

This primitive keeps the API and semantics of the underlying component and adds motion at the surface edges. Entrances are slower and more settled than exits, so closing never feels like waiting.

  • Springs for position, scale and size; tweens for colour and opacity.
  • The exit is shorter than the entrance, and keeps the current position as its starting point.
  • All measurements are taken again when content or font metrics change.
  • With reduced motion, the surface fades in place and never travels.
spring 300 / 30exit 150 msblur 4 pxheight 450 ms
04

API Reference

Every part takes exactly the props of the Hover Card primitive. The animated surface adds only motion props, so the accessibility tree and keyboard behaviour stay the same.

Hover Card

PropTypeDefault
childrenReactNode—
disabledbooleanfalse
transitionTransitionspring.press
classNamestring—

Next component

Input OTP

One-time-code inputs with popping characters and a pasted cascade.