We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

HoverCard Component

The HoverCard component creates elegant floating cards that appear when users hover over trigger elements. Perfect for displaying rich previews, detailed tooltips, or additional context without cluttering your interface.

  • Check Circle

    Smart Positioning: Automatically adjusts to stay within viewport

  • Check Circle

    Multiple Triggers: Support for multiple trigger elements

  • Check Circle

    Customizable Offset: Fine-tune card positioning

  • Check Circle

    Accessibility: Built-in ARIA support and keyboard navigation

Hover Card Title

This is some helpful information that appears when you hover.

Create a simple hover card with a trigger element:

<button class="trigger-button">Hover over me</button>
<HoverCard
role="tooltip"
triggerQuery=".trigger-button"
position="bottom"
offset={8}
>
<div class="p-4">
<h3>Preview Title</h3>
<p>Rich preview content goes here</p>
</div>
</HoverCard>

The HoverCard supports four positioning options:

Top Position

Card appears above the trigger element

Bottom Position

Card appears below the trigger element

Left Position

Card appears to the left of the trigger element

Right Position

Card appears to the right of the trigger element

HoverCard Component Extends <div> HTMLElement
Prop Type Default Description
role contentinfo | tooltip tooltip ARIA role for accessibility
position top | bottom | left | right bottom Card position relative to trigger
offset number 8 Distance from trigger in pixels
triggerQuery string CSS selector for trigger element(s)
viewportPadding number 8 Minimum distance from viewport edges
  1. Content Guidelines

    • Keep content concise and relevant
    • Use clear headings when needed
    • Maintain consistent styling
    • Consider mobile viewports
  2. Trigger Selection

    • Use descriptive trigger elements
    • Ensure adequate touch targets
    • Consider multiple triggers
    • Maintain logical grouping
User profiles
Feature previews
Rich tooltips
Context menus
Help text

Limited Time Launch Sale

Enhance your user interface with elegant hover cards. Get our AstroJS starter template now and access the complete UI toolkit!

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes