Unlock faster development with Fidely UI Pro components Coming soon

Hover Card

Used to display content when hovering over an element

@fidely_ui

Usage

import { HoverCard } from '@fidely-ui/react'
<HoverCard.Root>
  <HoverCard.Trigger />
  <HoverCard.Positioner>
    <HoverCard.Content>
      <HoverCard.Arrow>
        <HoverCard.ArrowTip />
      </HoverCard.Arrow>
    </HoverCard.Content>
  </HoverCard.Positioner>
</HoverCard.Root>

Controlled

Use the open and onOpenChange to control the visibility of the hover card.

Placement

Use the positioning.placement prop to configure the underlying Floating UI positioning logic, allowing you to control where the hover card appears relative to its trigger.

@fidely_ui

Delays

Control the open and close delays using the openDelay and closeDelay props.

@fidely_ui

Disabled

Use the disabled prop to prevent opening the hover card on interaction.

@fidely_ui

Using the RootProvider

The RootProvider component provides a context for the HoverCard. It accepts the value of the useHoverCard hook. You can leverage it to access the component state and methods from outside the HoverCard.

Within Dialog

To use the HoverCard within a Dialog, you need to avoid portalling the HoverCard.Positioner to the document's body.

/* <Portal> */
<HoverCard.Positioner>
  <HoverCard.Content>{/* ... */}</HoverCard.Content>
</HoverCard.Positioner>
/* </Portal> */

Accessibility

HoverCard should be used only for supplementary information that is not required to understand the primary content.

Hover cards are not accessible to screen readers and cannot be triggered via keyboard interaction. Avoid placing essential or actionable content inside a HoverCard.

Props

PropTypeDefaultDescription
closeDelaynumber300The duration from when the mouse leaves the trigger or content until the hover card closes.
openDelaynumber600The duration from when the mouse enters the trigger until the hover card opens.
lazyMountbooleanfalseWhether to enable lazy mounting.
skipAnimationOnMountbooleanfalseWhether to allow the initial presence animation.
unmountOnExitbooleanfalseWhether to unmount on exit.
asReact.ElementType-The underlying element to render.
asChildboolean-Use the provided child element as the default rendered element, combining their props and behavior
defaultOpenboolean-The initial open state of the hover card when rendered. Use when you don't need to control the open state of the hover card.
disabledboolean-Whether the hover card is disabled.
idstring-The unique identifier of the machine.
idsPartial<{}>-The ids of the elements in the hoverCard. Useful for composition
immediateboolean-Whether to synchronize the present change immediately or defer it to the next frame
onExitCompleteVoidFunction-Function called when the animation ends in the closed state
onInteractOutside(event: InteractOutsideEvent) => void-Function called when an interaction happens outside the component
onOpenChange(details: OpenChangeDetails) => void-Function called when the hover card opens or closes
onFocusOutside(event: FocusOutsideEvent) => void-Function called when the focus is moved outside the component
onPointerDownOutside(event: PointerDownOutsideEvent) => void-Function called when the pointer is pressed down outside the component
openboolean-The controlled open state of the hover card
positioningPositioningOptions-The user provided options used to position the popover content
presentboolean-Whether the node is present (controlled by the user)