HoverCard
Preview card on hover/focus of a link or avatar.
Code
import * as React from 'react';
import { Avatar, HoverCard, Link, Stack, Text } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
minHeight: 190,
}}
>
<HoverCard defaultOpen label="Ada Lovelace" trigger={<Link href="#">@ada</Link>}>
<Stack direction="row" gap={3}>
<Avatar name="Ada Lovelace" size={48} />
<Stack gap={1}>
<b>Ada Lovelace</b>
<Text size="footnote" tone="secondary">
Design lead · Joined 2024
</Text>
<Text size="footnote">Building the Fruit Design system.</Text>
</Stack>
</Stack>
</HoverCard>
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { HoverCard } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/hover-card.jsonGuidelines
- Content must also be reachable without hover (link to the page).
Props
| Prop | Type | Required |
|---|---|---|
trigger | React.ReactNode | Yes |
defaultOpen | boolean | No |
openDelay | number | No |
width | number | No |
label | string | No |
children | React.ReactNode | No |