Skip to content
OverlaysGenerated from the public API

HoverCard

A preview on hover that is also reachable by keyboard.

@luc/ui

Examples

Default

A preview on hover with a longer delay than a tooltip; the trigger is focusable and the card follows focus.

Usage

import { HoverCard, HoverCardTrigger, HoverCardContent } from "@luc/ui";
<HoverCard>
  <HoverCardTrigger asChild>
    <Link href="/people/ada">Ada Rensselaer</Link>
  </HoverCardTrigger>
  <HoverCardContent>
    Quantitative researcher, Rotterdam.
  </HoverCardContent>
</HoverCard>

Package setup — peer requirements, the stylesheet and the provider — is on installation.

API

Read from the published TypeScript API, so a prop that is not listed here does not exist and a default that is listed is the one the compiler sees.

Exported symbols
ExportKindSignature
HoverCard6 documented propsimport("@types/react").FC<RadixHoverCard.HoverCardProps>
HoverCardContent18 documented props({ className, width, align, sideOffset, ...props }: HoverCardContentProps) => import("@types/react").JSX.Element
HoverCardPortal3 documented propsimport("@types/react").FC<RadixHoverCard.HoverCardPortalProps>
HoverCardTrigger1 documented propsimport("@types/react").ForwardRefExoticComponent<RadixHoverCard.HoverCardTriggerProps & import("@types/react").RefAttributes<HTMLAnchorElement>>

HoverCard props

Type: HoverCardProps

Values the compiler reads from the declaration.

HoverCard props
PropTypeDefaultNotes
children?inheritedReactNode—
closeDelay?inheritednumber | undefined—
defaultOpen?inheritedboolean | undefined—
onOpenChange?inherited((open: boolean) => void) | undefined—
open?inheritedboolean | undefined—
openDelay?inheritednumber | undefined—

HoverCardContent props

Type: HoverCardContentProps

Values the compiler reads from the declaration.

HoverCardContent props
PropTypeDefaultNotes
align?inherited"center" | "start" | "end" | undefined—
alignOffset?inheritednumber | undefined—
arrowPadding?inheritednumber | undefined—
asChild?inheritedboolean | undefined—
avoidCollisions?inheritedboolean | undefined—
collisionBoundary?inheritedBoundary | Boundary[] | undefined—
collisionPadding?inheritednumber | Partial<Record<"top" | "right" | "bottom" | "left", number>> | undefined—
forceMount?inheritedtrue | undefined—Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
hideWhenDetached?inheritedboolean | undefined—
onEscapeKeyDown?inherited((event: KeyboardEvent) => void) | undefined—Event handler called when the escape key is down. Can be prevented.
onFocusOutside?inherited((event: FocusOutsideEvent) => void) | undefined—Event handler called when the focus moves outside of the `HoverCard`. Can be prevented.
onInteractOutside?inherited((event: PointerDownOutsideEvent | FocusOutsideEvent) => void) | undefined—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?inherited((event: PointerDownOutsideEvent) => void) | undefined—Event handler called when the a `pointerdown` event happens outside of the `HoverCard`. Can be prevented.
side?inherited"top" | "right" | "bottom" | "left" | undefined—
sideOffset?inheritednumber | undefined—
sticky?inherited"partial" | "always" | undefined—
updatePositionStrategy?inherited"always" | "optimized" | undefined—
width?"sm" | "md" | "lg" | undefined—

HoverCardPortal props

Type: HoverCardPortalProps

Values the compiler reads from the declaration.

HoverCardPortal props
PropTypeDefaultNotes
children?inheritedReactNode—
container?inheritedElement | DocumentFragment | null | undefined—Specify a container element to portal the content into.
forceMount?inheritedtrue | undefined—Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.

HoverCardTrigger props

Type: HoverCardTriggerProps & RefAttributes<HTMLAnchorElement>

Values the compiler reads from the declaration.

HoverCardTrigger props
PropTypeDefaultNotes
asChild?inheritedboolean | undefined—

Guidelines

Do

  • Use it for a preview of what a link leads to — a person, a document, a definition — where the reader may continue without following it.
  • Keep the trigger focusable: the card opens on focus as well as hover, which is what makes it usable from the keyboard.

Don't

  • Use it for essential information or for anything interactive the reader must reach; the card has no dismissal lifecycle of its own.

Accessibility

The trigger is a link or button, so it is reachable in reading order; opening the card does not move focus, and the card's content is read in place rather than being a modal.

What happens on the server, and when hydration changes it.

Family

Overlays

Content that leaves the flow, or reveals itself in place — and the focus contract that has to come with it.

10 documented entries in this family. Open the family index

Luc UI v1.0HoverCarddark theme