Skip to content

Hover Card Primitive

Hooks Primitives Portal Primitives Slot Primitives Types Primitives

@radix-ui/react-hover-card


Allows users with vision to preview the content hidden behind an element before hovering or pressing.

Installation

Install @radix-ui/react-hover-card

Terminal window
npx expo install @radix-ui/react-hover-card

Copy/paste the following code for web to ~/components/primitives/hover-card/hover-card.web.tsx

Copy/paste the following code for native to ~/components/primitives/hover-card/hover-card.tsx

Copy/paste the following code for types to ~/components/primitives/hover-card/types.ts

Copy/paste the following code for exporting to ~/components/primitives/hover-card/index.ts

Usage

import * as HoverCardPrimitive from '~/components/primitives/hover-card';
import { Text, View } from 'react-native';
function Example() {
return (
<HoverCardPrimitive.Root>
<HoverCardPrimitive.Trigger>
<Text>@nextjs</Text>
</HoverCardPrimitive.Trigger>
<HoverCardPrimitive.Content>
<View>
<Text>@nextjs</Text>
<Text>
The React Framework – created and maintained by @vercel.
</Text>
<View>
<Text>
Joined December 2021
</Text>
</View>
</View>
</HoverCardPrimitive.Content>
</HoverCardPrimitive.Root>
);
}

Props

Root

Extends View props

PropTypeNote
openboolean(optional)
onOpenChange(value: boolean) => void(optional)
defaultOpenboolean(optional)
asChildboolean(optional)
relativeTo’longPress’ | ‘trigger’Native Only_(optional)_

Trigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

Portal

PropTypeNote
children*React.ReactNode
forceMounttrue | undefined(optional)
hostNamestringWeb Only (optional)
containerHTMLElement | null | undefinedWeb Only (optional)

Overlay

Extends Pressable props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined;(optional)

Content

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined(optional)
alignOffsetnumber(optional)
insetsInsets(optional)
avoidCollisionsboolean(optional)
align’start’ | ‘center’ | ‘end’(optional)
side’top’ | ‘bottom’(optional)
sideOffsetnumber(optional)
disablePositioningStylebooleanNative Only (optional)
collisionBoundaryElement | null | Array<Element | null>Web Only (optional)
sticky’partial’ | ‘always’Web Only (optional)
hideWhenDetachedbooleanWeb Only (optional)

useRootContext

Must be used within a Root component. It provides the following values from the dropdown menu: open, and onOpenChange.