snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
136
apps/v4/content/docs/components/aria/hover-card.mdx
Normal file
136
apps/v4/content/docs/components/aria/hover-card.mdx
Normal file
@@ -0,0 +1,136 @@
|
||||
---
|
||||
title: Hover Card
|
||||
description: A popover that appears on hover, focus, or long press to preview content available behind a link.
|
||||
base: aria
|
||||
component: true
|
||||
links:
|
||||
doc: https://react-aria.adobe.com/PreviewTrigger
|
||||
api: https://react-aria.adobe.com/PreviewTrigger#api
|
||||
---
|
||||
|
||||
<ComponentPreview
|
||||
styleName="aria-nova"
|
||||
name="hover-card-demo"
|
||||
previewClassName="h-80"
|
||||
/>
|
||||
|
||||
## Installation
|
||||
|
||||
<CodeTabs>
|
||||
|
||||
<TabsList>
|
||||
<TabsTrigger value="cli">Command</TabsTrigger>
|
||||
<TabsTrigger value="manual">Manual</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="cli">
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add hover-card
|
||||
```
|
||||
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="manual">
|
||||
|
||||
<Steps className="mb-0 pt-2">
|
||||
|
||||
<Step>Install the following dependencies:</Step>
|
||||
|
||||
```bash
|
||||
npm install react-aria-components
|
||||
```
|
||||
|
||||
<Step>Copy and paste the following code into your project.</Step>
|
||||
|
||||
<ComponentSource
|
||||
name="hover-card"
|
||||
title="components/ui/hover-card.tsx"
|
||||
styleName="aria-nova"
|
||||
/>
|
||||
|
||||
<Step>Update the import paths to match your project setup.</Step>
|
||||
|
||||
</Steps>
|
||||
|
||||
</TabsContent>
|
||||
|
||||
</CodeTabs>
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx showLineNumbers
|
||||
import { HoverCard, HoverCardTrigger } from "@/components/ui/hover-card"
|
||||
```
|
||||
|
||||
```tsx showLineNumbers
|
||||
<HoverCardTrigger>
|
||||
<Button variant="link">Hover</Button>
|
||||
<HoverCard>
|
||||
The React Framework – created and maintained by @vercel.
|
||||
</HoverCard>
|
||||
</HoverCardTrigger>
|
||||
```
|
||||
|
||||
## Composition
|
||||
|
||||
Use the following composition to build a `HoverCard`:
|
||||
|
||||
```text
|
||||
HoverCardTrigger
|
||||
├── Button
|
||||
└── HoverCard
|
||||
```
|
||||
|
||||
## Trigger Delays
|
||||
|
||||
Use `delay` and `closeDelay` on the `HoverCardTrigger` to control when the card
|
||||
opens and closes.
|
||||
|
||||
```tsx showLineNumbers
|
||||
<HoverCardTrigger delay={100} closeDelay={200}>
|
||||
<Button variant="link">Hover</Button>
|
||||
<HoverCard>Content</HoverCard>
|
||||
</HoverCardTrigger>
|
||||
```
|
||||
|
||||
## Positioning
|
||||
|
||||
Use the `placement` prop on `HoverCard` to control placement.
|
||||
|
||||
```tsx showLineNumbers
|
||||
<HoverCardTrigger>
|
||||
<Button variant="link">Hover</Button>
|
||||
<HoverCard placement="top">Content</HoverCard>
|
||||
</HoverCardTrigger>
|
||||
```
|
||||
|
||||
## Basic
|
||||
|
||||
<ComponentPreview
|
||||
styleName="aria-nova"
|
||||
name="hover-card-demo"
|
||||
previewClassName="h-80"
|
||||
/>
|
||||
|
||||
## Sides
|
||||
|
||||
<ComponentPreview
|
||||
styleName="aria-nova"
|
||||
name="hover-card-sides"
|
||||
previewClassName="h-[22rem]"
|
||||
/>
|
||||
|
||||
## RTL
|
||||
|
||||
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
|
||||
|
||||
<ComponentPreview
|
||||
styleName="aria-nova"
|
||||
name="hover-card-rtl"
|
||||
direction="rtl"
|
||||
previewClassName="h-80"
|
||||
/>
|
||||
|
||||
## API Reference
|
||||
|
||||
See the [React Aria](https://react-aria.adobe.com/PreviewTrigger#api) documentation for more information.
|
||||
Reference in New Issue
Block a user