Skip to Content

Built by moveinready.casa  and the community

Shadcn Docs

Radix Docs

Hover Card

For sighted users to preview content available behind a link.

Usage

import { HoverCard, HoverCardTrigger, HoverCardContent, } from "@/components/ui/hover-card"; <HoverCard> <HoverCardTrigger asChild> <Button>Hover me</Button> </HoverCardTrigger> <HoverCardContent> <Text>Hover card content goes here.</Text> </HoverCardContent> </HoverCard>;

Composition

You can compose this component with the card component to create a more complex hover card.

<View className="w-full items-start gap-4 p-4"> <HoverCard> <HoverCardTrigger>Hover me</HoverCardTrigger> <HoverCardContent asChild {...args}> <Card className="bg-popover-foreground"> <CardHeader> <CardTitle>Card Title</CardTitle> <CardDescription> A brief description of the card content goes here. </CardDescription> </CardHeader> <CardContent> This is the main content area of the card. You can place any content here such as text, images, or other components. </CardContent> </Card> </HoverCardContent> </HoverCard> </View>

Components

HoverCard

PropTypeDefaultDescription
defaultOpenbooleanfalseUncontrolled initial open state of the hover card.
openboolean-Controlled open state of the hover card.
onOpenChange(isOpen: boolean) => void-Callback invoked when the hover card open state changes.
baseClassNamestring-Custom tailwind classes to apply to the base hover card container. Takes priority over the className.

Also extends all React Native View component props.

HoverCardTrigger

PropTypeDefaultDescription
disabledbooleanfalseWhether the hover card trigger is disabled.
loadingbooleanfalseWhether the hover card trigger is loading (disables interactions).
asChildbooleanfalseIf true clones the child and passes all accessibility and functionality props to it. Available on any exported component.
baseClassNamestring-Custom tailwind classes to apply to the base trigger component. Takes priority over the className prop.
textClassNamestring-Custom tailwind classes to apply to the trigger text.

Also extends all React Native Pressable component props.

HoverCardContent

PropTypeDefaultDescription
asChildbooleanfalseIf true clones the child and passes all accessibility and functionality props to it. Available on any exported component.
baseClassNamestring-Custom tailwind classes to apply to the base content component. Takes priority over the className prop.
textClassNamestring-Custom tailwind classes to apply to the inner text.

Also extends all React Native View component props.

Hooks

useHoverCard

The backbone hook for the hover card component that manages state and provides root hover-out behavior.

Parameters:

ParameterTypeDefaultDescription
defaultOpenbooleanfalseUncontrolled initial open state of the hover card.
openboolean-Controlled open state of the hover card.
onOpenChange(isOpen: boolean) => void-Callback when the hover card open state changes.

Returns:

{ state: { isOpen: boolean; setIsOpen: (isOpen: boolean) => void; isControlled: boolean; }; componentProps: ComponentProps<typeof View> | HTMLDivElement; }
PropertyTypeDescription
state.isOpenbooleanWhether the hover card is open.
state.setIsOpen(isOpen: boolean) => voidFunction to set the open state of the hover card.
state.isControlledbooleanWhether the open state is controlled.
componentPropsComponentProps<typeof View> | HTMLDivElementEvent props (e.g., onMouseLeave) for the root hit box container.

useHoverCardTrigger

Hook for the hover card trigger that provides accessibility and interaction props.

Parameters:

ParameterTypeDefaultDescription
stateHoverCardReturn['state']-Required. The hover card state from useHoverCard.
disabledbooleanfalseWhether the trigger is disabled.
loadingbooleanfalseWhether the trigger is loading (disables input).

Returns:

{ componentProps: ComponentProps<typeof Pressable> | HTMLButtonElement; }
PropertyTypeDescription
componentPropsComponentProps<typeof Pressable> | HTMLButtonElementAccessibility and interaction props for the trigger.

useHoverCardContent

Hook for the hover card content that returns animated props and styles.

Parameters:

ParameterTypeDefaultDescription
stateHoverCardReturn['state']-Required. The hover card state.

Returns:

{ componentProps: ComponentProps<typeof Reanimated.View>; }
PropertyTypeDescription
componentPropsComponentProps<typeof Reanimated.View>Animated props and styles for the content container.

Accessibility

  • Uses useButton and useFocusRing for web a11y on the trigger.
  • Trigger supports keyboard focus to open content.
  • Content visibility is controlled and announced through standard ARIA state on the trigger.

shadcn-native

Built by moveinready.casa and the community