Skip to content

Hover Card

Hover Card Primitive

Demo


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

Installation

Terminal window
npx @react-native-reusables/cli@latest add hover-card

Usage

import { View } from 'react-native';
import { Avatar, AvatarFallback, AvatarImage } from '~/components/ui/avatar';
import { Button } from '~/components/ui/button';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '~/components/ui/hover-card';
import { Text } from '~/components/ui/text';
import { CalendarDays } from '~/lib/icons/CalendarDays';
function Example() {
return (
<View className='flex-1 justify-center items-center p-6 gap-12'>
<HoverCard>
<HoverCardTrigger asChild>
<Button variant='link' size='lg'>
<Text>@nextjs</Text>
</Button>
</HoverCardTrigger>
<HoverCardContent className='w-80 native:w-96'>
<View className='flex flex-row justify-between gap-4'>
<Avatar alt='Vercel avatar'>
<AvatarImage source={{ uri: 'https://github.com/vercel.png' }} />
<AvatarFallback>
<Text>VA</Text>
</AvatarFallback>
</Avatar>
<View className='gap-1 flex-1'>
<Text className='text-sm native:text-base font-semibold'>@nextjs</Text>
<Text className='text-sm native:text-base'>
The React Framework – created and maintained by @vercel.
</Text>
<View className='flex flex-row items-center pt-2 gap-2'>
<CalendarDays size={14} className='text-foreground opacity-70' />
<Text className='text-xs native:text-sm text-muted-foreground'>
Joined December 2021
</Text>
</View>
</View>
</View>
</HoverCardContent>
</HoverCard>
</View>
);
}

Props

HoverCard

Extends View props

PropTypeNote
onOpenChange(value: boolean) => void
asChildboolean(optional)
relativeTo’longPress’ | ‘trigger’Native Only (optional)

HoverCardTrigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

HoverCardContent

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)