Hover Preview
Interactive text image previews when hovering over target words.
hover-preview-tw
Built with React, TypeScript, and brought to life with Motion.
Customize
Tweak the props livePosition & Animation
0.2s
0.15s
12°
15px
Image Settings
200px
200px
Target Settings
4px
Props
| Name | Type | Default | Description |
|---|---|---|---|
content | string | "" | Text content with placeholders for targets (use {0}, {1}, etc.) |
targets | HoverTarget[] | [] | Array of target configurations with text, imageUrl, linkUrl, and altText |
onTargetClick | (target: HoverTarget, index: number) => void | undefined | Callback when a target is clicked. If not provided and linkUrl exists, opens link in new tab |
imagePosition | "above" | "below" | "left" | "right" | "above" | Position of the image relative to the target text |
enterSpeed | number | 0.2 | Enter animation duration in seconds |
exitSpeed | number | 0.15 | Exit animation duration in seconds |
maxRotation | number | 12 | Maximum rotation angle for the image (in degrees) |
maxOffset | number | 15 | Maximum offset for image movement (in pixels) |
imageWidth | number | 200 | Image width in pixels |
imageHeight | number | 200 | Image height in pixels |
className | string | "" | Additional CSS classes for the container |
targetClassName | string | "" | Additional CSS classes for target text |
targetPadding | number | 4 | Padding around target text to expand hover area (in pixels) |
imageBorderRadius | string | "0.75rem" | Image border radius (CSS value) |
showImageShadow | boolean | true | Show shadow on image preview |
contentstringText content with placeholders for targets (use {0}, {1}, etc.)
Default:
""targetsHoverTarget[]Array of target configurations with text, imageUrl, linkUrl, and altText
Default:
[]onTargetClick(target: HoverTarget, index: number) => voidCallback when a target is clicked. If not provided and linkUrl exists, opens link in new tab
Default:
undefinedimagePosition"above" | "below" | "left" | "right"Position of the image relative to the target text
Default:
"above"enterSpeednumberEnter animation duration in seconds
Default:
0.2exitSpeednumberExit animation duration in seconds
Default:
0.15maxRotationnumberMaximum rotation angle for the image (in degrees)
Default:
12maxOffsetnumberMaximum offset for image movement (in pixels)
Default:
15imageWidthnumberImage width in pixels
Default:
200imageHeightnumberImage height in pixels
Default:
200classNamestringAdditional CSS classes for the container
Default:
""targetClassNamestringAdditional CSS classes for target text
Default:
""targetPaddingnumberPadding around target text to expand hover area (in pixels)
Default:
4imageBorderRadiusstringImage border radius (CSS value)
Default:
"0.75rem"showImageShadowbooleanShow shadow on image preview
Default:
true