Panels and menusInteractive playground
HoverCard
A contextual preview on hover or focus.
Preparing the playground…
Text and Markdown example
HoverCard · Example
1<HoverCard><HoverCardTrigger asChild><a href="/docs" style={{color:"var(--color-primary)"}}>@kivora</a></HoverCardTrigger><HoverCardContent>Components for the web and your next big idea.</HoverCardContent></HoverCard>How to use it
The content is supplementary: essential information must also be available at the linked destination.
Import
React / Next.js
1import { HoverCard, HoverCardTrigger, HoverCardContent } from "@kivora/nextjs";Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.
API reference 0.2.0
Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.
| Property | Type | Description |
|---|---|---|
children | ReactNode | Content or child elements of the component. |
closeDelay | number | Configures closeDelay. The type describes the supported values and structure. |
defaultOpen | boolean | Whether it starts open in uncontrolled mode. |
onOpenChange | ((open: boolean) => void) | Receives the new open state. |
open | boolean | Controlled open state. |
openDelay | number | Configures openDelay. The type describes the supported values and structure. |
Subcomponents and composition
Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.
HoverCard6 properties
HoverCard · TypeScript
1declare function HoverCard({ closeDelay, defaultOpen, open, onOpenChange, openDelay, ...props }: HoverCardProps): React.JSX.Element;HoverCardTrigger15 properties
| Property | Type | Description |
|---|---|---|
aria-label | string | Accessible name of the control. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLAnchorElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLAnchorElement> | Action performed when the element is activated. |
onSubmit | SubmitEventHandler<HTMLAnchorElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
type | string | Operation type or mode; values depend on the component. |
HoverCardTrigger · TypeScript
1HoverCardTrigger: React.ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & React.RefAttributes<HTMLAnchorElement>>HoverCardContent30 properties
| Property | Type | Description |
|---|---|---|
align | "center" | "start" | "end" | Content alignment. |
alignOffset | number | Offset from the chosen alignment. |
aria-label | string | Accessible name of the control. |
arrowPadding | number | Configures arrowPadding. The type describes the supported values and structure. |
asChild | boolean | Apply props and behavior to a single compatible child element. |
avoidCollisions | boolean | Configures avoidCollisions. The type describes the supported values and structure. |
children | ReactNode | Content or child elements of the component. |
className | string | Additional CSS classes to customize the element. |
collisionBoundary | Boundary | Boundary[] | Configures collisionBoundary. The type describes the supported values and structure. |
collisionPadding | number | Partial<Record<"left" | "right" | "top" | "bottom", number>> | Configures collisionPadding. The type describes the supported values and structure. |
defaultChecked | boolean | Initial selection of the control. |
defaultValue | string | number | readonly string[] | Initial value when the component manages its own state. |
forceMount | true | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
hideWhenDetached | boolean | Configures hideWhenDetached. The type describes the supported values and structure. |
id | string | Element identifier; associates labels and descriptions. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | Change event. Check the type: some controls return an object, others a DOM event. |
onClick | MouseEventHandler<HTMLDivElement> | Action performed when the element is activated. |
onEscapeKeyDown | ((event: KeyboardEvent) => void) | Event handler called when the escape key is down. Can be prevented. |
onFocusOutside | ((event: FocusOutsideEvent) => void) | Event handler called when the focus moves outside of the `HoverCard`. Can be prevented. |
onInteractOutside | ((event: PointerDownOutsideEvent | FocusOutsideEvent) => void) | Event handler called when an interaction happens outside the `HoverCard`. Specifically, when a `pointerdown` event happens outside or focus moves outside of it. Can be prevented. |
onPointerDownOutside | ((event: PointerDownOutsideEvent) => void) | Event handler called when the a `pointerdown` event happens outside of the `HoverCard`. Can be prevented. |
onSubmit | SubmitEventHandler<HTMLDivElement> | Form submission event. |
role | AriaRole | Semantic role of the element. Keep the default role unless a change is justified. |
side | "left" | "right" | "top" | "bottom" | Side from which the panel appears. |
sideOffset | number | Distance between the trigger and content. |
sticky | "partial" | "always" | Configures sticky. The type describes the supported values and structure. |
style | CSSProperties | React inline styles. |
tabIndex | number | Keyboard focus order and availability. |
title | string | Title or supplementary information. |
updatePositionStrategy | "always" | "optimized" | Configures updatePositionStrategy. The type describes the supported values and structure. |
HoverCardContent · TypeScript
1HoverCardContent: React.ForwardRefExoticComponent<HoverCardContentProps & React.RefAttributes<HTMLDivElement>>API generated from @kivora/nextjs 0.2.0View package