Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Overlays

HoverCard

A passive preview beside its anchor, such as a larger thumbnail of the page under the pointer.

Previews the hovered item

When to useLink to "When to use"

  • A bigger look at something small (a page thumbnail, an image, a colour) while it is hovered or focused.

Use something else when:

UsageLink to "Usage"

tsx
Copy
import { HoverCard } from "@arshad-shah/cynosure";

<HoverCard open={hovered !== null} anchor={thumbRef}>
  <img src={large} alt="" />
</HoverCard>

You decide when it shows: open it on pointer enter and on focus, so keyboard users see the same preview.

PropsLink to "Props"

Every prop of HoverCard
PropWhat it doesTypeDefault
openRequired
Show it. The owner decides when: a hovered row, a focused thumbnail.boolean
anchorRequired
What it previews: a ref to an element, or a virtual anchor.FloatingAnchor
placement
Preferred side; it flips when there is no room and slides to stay on screen. Default end.Placement`end`
children
The preview (a larger thumbnail, a summary). Nothing in it can be clicked or focused.ReactNode
className
Added to the root element, for layout.string
style
Layout only. Restyle through --cy-hover-card-* tokens.CSSProperties

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

  • Passive: aria-hidden, inert and pointer-events: none. The pointer passes through it and focus never enters it; it repeats what the anchor already names, so nothing is lost to screen readers.
  • Placement: on the placement side, flipping when there is no room and sliding to stay inside the viewport.
  • Isolation: top layer through the Popover API, rendered in place, so it works in shadow roots and above any z-index.
Flips when there is no room

ThemingLink to "Theming"

Tokens: --cy-hover-card-background, --cy-hover-card-radius, --cy-hover-card-padding and --cy-hover-card-offset.

Tooltip · Popover · FloatingToolbar

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog