Overlays & Actions
Hover Card
Rich preview on hover or focus — delays, asChild trigger, side/align positioning, shadcn-aligned examples. Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/hover-card.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import HoverCard, HoverCardTrigger and HoverCardContent from @/components/kamod-ui/hover-card.
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Wrap a trigger and content. Use openDelay and closeDelay on HoverCard to avoid accidental opens. Use HoverCardTrigger asChild to use a Button or link. Position content with side and align on HoverCardContent.
import { HoverCard } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Hover Card in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Demo
Offer Supplementary Context without Requiring It. Use a link-style trigger with a structured hover-card body to reveal supplementary context about a person or resource. The compact preview adds detail near the reference without turning the page into a permanently expanded profile.
Keep essential information available elsewhere for touch and keyboard users, and choose Popover when the panel must contain a deliberate interactive workflow.
import { Button, HoverCard, HoverCardContent, HoverCardTrigger } from "@kamod-ch/ui";
export const Example = () => (
<HoverCard openDelay={10} closeDelay={100}>
<HoverCardTrigger asChild>
<Button variant="link">Hover Here</Button>
</HoverCardTrigger>
<HoverCardContent class="flex w-64 flex-col gap-0.5">
<div class="font-semibold">@nextjs</div>
<div>The React Framework – created and maintained by @vercel.</div>
<div class="text-muted-foreground mt-1 text-xs">Joined December 2021</div>
</HoverCardContent>
</HoverCard>
);Usage
Keep the Trigger Understandable without the Preview. Start with HoverCardTrigger and HoverCardContent to understand their relationship before adding a custom trigger style. The content should remain supplemental, with the page's main meaning available even when the card is closed.
Do not put the only explanation of an unfamiliar action inside a hover-only surface, and verify how the surrounding page behaves without pointer hover.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthTrigger Delays
Balance Responsiveness with Accidental Activation. Set openDelay and closeDelay on HoverCard to tune how quickly the preview appears and disappears. A short delay can reduce accidental openings while leaving enough time to move toward the displayed content.
Tune delays with realistic pointer movement and content length, and keep the preview supplementary rather than extending it into a hidden task interface.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthPositioning
Keep the Preview Visually Attached to Its Trigger. Set side and align on HoverCardContent to place the preview relative to its trigger. Choose a position that leaves room for the content and does not obscure the information that prompted the hover.
Test triggers near viewport edges and inside scrolling regions, and avoid large offsets that make it unclear which link produced the card.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthSides
Compare Placement Using Realistic Content. Compare top, right, bottom and left placement using the same hover-card content. The side choice affects where the supplemental panel fits, while its label, purpose and underlying reference remain unchanged.
Inspect each edge of the viewport and choose a consistent default; placement should support reading rather than alternate arbitrarily between nearby triggers.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Hover Card using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.HoverCard
HoverCardProps
| Prop / type | Description |
|---|---|
children | Configure
|
closeDelay | Delay before closing (ms). Radix default 300.
|
defaultOpen | Configure
|
openDelay | Delay before opening (ms). Radix default 700.
|
HoverCardContent
HoverCardContentProps
| Prop / type | Description |
|---|---|
align | Configure
|
children | Configure
|
class | Configure
|
onKeyDown | Configure
|
onMouseEnter | Configure
|
onMouseLeave | Configure
|
side | Configure
|
sideOffset | Configure
|
style | Configure
|
HoverCardTrigger
HoverCardTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
class | Configure
|
onBlur | Configure
|
onFocus | Configure
|
onMouseEnter | Configure
|
onMouseLeave | Configure
|
ref | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
HoverCardContextValue
7 declared fieldsHoverCardContextValueHoverCard.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of HoverCardContextValue before adapting it.open, openDelay, closeDelay, scheduleOpen, scheduleClose, pinOpen, setOpenImmediateHoverCard Props
4 declared fieldsHoverCardPropsHoverCard.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of HoverCardProps before adapting it.HoverCardContent Props
4 declared fieldsHoverCardContentPropsHoverCardContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of HoverCardContentProps before adapting it.HoverCardTrigger Props
2 declared fieldsHoverCardTriggerPropsHoverCardTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of HoverCardTriggerProps before adapting it.Accessibility
Build the Complete Interaction, Including the Parts Outside Hover Card. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
HoverCard opens on pointer hover and trigger focus, and its content uses a non-modal dialog role. Escape dismisses the content. Opening on focus makes it more discoverable than pointer-only content, but it is still supplemental information.
Labels and Relationships
Keep the trigger a meaningful destination or subject, such as a person's name. Give the panel an understandable name when its contents form a distinct dialog-like region, and avoid repeating a long profile as the trigger's accessible name.
Keyboard and Focus
Test focus moving from the trigger toward any interactive content and then away. Delayed opening and closing must not prevent users from reaching a link. Keep the underlying profile or detail page available through a normal navigation path.
States and Integration Details
Do not require hover-card access to complete an essential action. Small pointer gaps, touch input and screen-reader navigation can change how the surface is encountered. Use a deliberate popover or dialog for a task that must remain open.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Open through focus as well as hover and dismiss using Escape.
- Reach any panel links without the card closing prematurely or trapping focus.
- Verify the same important information is available through a persistent page or control.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.