Components
- Accordion
- Action Bar
- Action Toast
- Alert Banner
- Alert Dialog
- Alert
- Alphabet Index
- Amount Field
- Aspect Ratio
- Attachment
- Availability List
- Avatar
- Badge
- Bank Card
- Breadcrumb
- Bubble
- Button Group
- Button
- Calendar
- Camera Frame
- Card Design Picker
- Card Details
- Card Peek
- Card Stack
- Card
- Carousel
- Chart
- Chat Thread
- Checkbox
- Chip Group
- Choice Tile
- Code Block
- Code Dots
- Collapsible
- Combobox
- Command
- Context Menu
- Copy Field
- Countdown
- Country Select
- Data Table
- Date Field
- Date Picker
- Date Range Picker
- Dialog
- Direction
- Document Paper
- Drawer
- Dropdown Menu
- Empty
- Entity Avatar
- Field
- File Trigger
- File Upload Item
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Key Value
- Keypad
- Label
- Live Region
- Marker
- Message Scroller
- Message
- Money Amount
- Native Select
- Number Field
- Pagination
- Percent Split Editor
- Phone Field
- Popover
- Progress
- QR Code
- Questionnaire
- Radio Group
- Range Histogram
- Rating
- Resizable
- Scroll Area
- Search Field
- Select
- Separator
- Share Bar
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Sortable List
- Spinner
- Status Timeline
- Step Header
- Steps List
- Swipe Row
- Switch
- Table
- Tabs
- Text Field
- Textarea
- Tier Ladder
- Toggle Group
- Toggle
- Token Search Field
- Tooltip
- Trace
- Transaction Row
- Usage Meter
Registry
"use client"
import { Button } from "@/components/ui/button"Use a hover card to preview extra detail behind a link, such as a contact's handle and join date next to a payee name. It opens on hover, focus or long press and can hold interactive content. Pick a tooltip for a short text label, and a popover when the content should open on press.
Installation#
pnpm dlx shadcn@latest add @dots/hover-card
Usage#
import { HoverCard, HoverCardTrigger } from "@/components/ui/hover-card"<HoverCardTrigger>
<Button variant="link">Maria Lopez</Button>
<HoverCard>Maria Lopez joined in March 2024.</HoverCard>
</HoverCardTrigger>Composition#
Use the following composition to build a HoverCard:
HoverCardTrigger
├── Button
└── HoverCardFeatures#
- Opens on hover, keyboard focus and long press.
- Separate open and close delays.
- Placement with automatic flipping and an arrow that tracks the trigger.
- Content can hold links and buttons.
Trigger delays#
Use delay and closeDelay on HoverCardTrigger to control when the card opens and closes.
<HoverCardTrigger delay={100} closeDelay={200}>
<Button variant="link">Maria Lopez</Button>
<HoverCard>Maria Lopez joined in March 2024.</HoverCard>
</HoverCardTrigger>Sides#
Use the placement prop on HoverCard to set the side. The card flips when there is no room.
"use client"
import { Button } from "@/components/ui/button"
Accessibility#
- The trigger must be a focusable element, such as a
Buttonor a link, so keyboard users can open the card with focus. - The card is non-modal and does not trap focus.
- Hover is not available on every device. Do not put the only copy of key information, such as an amount or a status, inside the card.
API Reference#
HoverCardTrigger#
Wraps the trigger and the card and holds the open state.
| Prop | Type | Default |
|---|---|---|
delay | number | 400 |
closeDelay | number | 150 |
isOpen | boolean | - |
defaultOpen | boolean | - |
onOpenChange | (isOpen: boolean) => void | - |
isDisabled | boolean | - |
children | ReactNode | - |
HoverCard#
The card. Other popover props pass through.
| Prop | Type | Default |
|---|---|---|
placement | Placement | "bottom" |
offset | number | 10 |
crossOffset | number | 0 |
containerPadding | number | 16 |
arrowBoundaryOffset | number | 18 |
showArrow | boolean | true |
className | string | - |