Hover Card
A preview card for supplementary link information.
Give your AI assistant this page as context.
Connect your library with MCPui/hover-cardUsage
Get this component from a saved library export or the connected CLI. The imports below refer to local files installed in your app.
Import styles/components.css, then styles/theme.css once. Wrap your app in ThemeScope from components/ui/utils so typography, focus and overlays share the theme. The installation guide covers runtime dependencies and React/Next.js setup.
import { HoverCard } from './components/ui/hover-card';
<HoverCard label="@alex" href="#profile"><strong>Alex Morgan</strong><p className="cr-description">Designer and developer.</p></HoverCard>Design system
This component consumes your semantic colors, spacing, typography and shape tokens. Import the compiled styles and your theme once as described in Export.
Behavior and accessibility
- Provide meaningful labels for interactive controls.
- Connect action callbacks to your application logic.
- Verify keyboard navigation and contrast in your application.
Status: experimental during early access. Sample previews do not send emails, process payments or upload files to a service.
Source and props
This is the exported source, using the same implementation as the editor.
"use client";
import { PreviewCard as Base } from "@base-ui/react/preview-card";
import type { ComponentProps, ReactNode } from "react";
import { usePortalContainer } from "./utils";
export function HoverCard({
label,
href,
children,
side = "bottom",
align = "start",
...rootProps
}: Omit<ComponentProps<typeof Base.Root>, "children"> & {
label: string;
href: string;
children: ReactNode;
side?: ComponentProps<typeof Base.Positioner>["side"];
align?: ComponentProps<typeof Base.Positioner>["align"];
}) {
const container = usePortalContainer();
return (
<Base.Root {...rootProps}>
<Base.Trigger href={href} className="cr-link">
{label}
</Base.Trigger>
<Base.Portal container={container}>
<Base.Positioner
side={side}
align={align}
sideOffset={8}
className="cr-positioner"
>
<Base.Popup className="cr-popup cr-hover-card">{children}</Base.Popup>
</Base.Positioner>
</Base.Portal>
</Base.Root>
);
}