SutraUI.HoverCard (Sutra UI v0.4.0)
View SourceA rich preview card that appears on hover or keyboard focus.
Composes a trigger with a floating content card. Shows on hover after a configurable delay, hides after a close delay. Useful for user profiles, item previews, or any contextual detail that shouldn't require a click.
Reuses the shared [data-popover] positioning system — same data-side and
data-align semantics as Popover and Tooltip.
Examples
<.hover_card id="user-card">
<:trigger>
<.button variant="link">@jane</.button>
</:trigger>
<div class="flex items-center gap-3">
<.avatar src="/jane.jpg" initials="JC" />
<div>
<p class="font-medium">Jane Cooper</p>
<p class="text-sm text-muted-foreground">@jane · Designer</p>
</div>
</div>
</.hover_card>
<.hover_card id="release-card" side="top" align="start">
<:trigger>Release notes</:trigger>
<div>
<p class="font-medium">v0.4.0</p>
<p class="text-sm text-muted-foreground">New display primitives.</p>
</div>
</.hover_card>Attributes
id- Required. Unique identifier.side- Side to place the card:top,bottom,left,right, orauto(dynamic viewport-aware placement). Defaults tobottom.align- Alignment relative to the trigger:start,center,end. Defaults tocenter.open_delay- Open delay in milliseconds. Defaults to150.close_delay- Close delay in milliseconds. Defaults to100.class- Additional CSS classes for the content card.
Slots
:trigger- Required. The hover/focus target.:inner_block- Required. The hover card content.
Accessibility
- The trigger sets
aria-expandedandaria-describedbylinking to the card. - The card uses
role="tooltip"for non-modal descriptive preview content and togglesaria-hidden. - Opens on both
mouseenterandfocusin— keyboard users get the same preview as mouse users. - Escape key closes the card.
Summary
Functions
Attributes
id(:string) (required) - Unique identifier for the hover card.side(:string) - Side to place the card —autoenables viewport-aware placement. Defaults to"bottom". Must be one of"top","bottom","left","right", or"auto".align(:string) - Alignment relative to the trigger. Defaults to"center". Must be one of"start","center", or"end".open_delay(:integer) - Open delay in milliseconds. Defaults to150.close_delay(:integer) - Close delay in milliseconds. Defaults to100.class(:any) - Additional CSS classes for the content card. Defaults tonil.- Global attributes are accepted. Additional HTML attributes.
Slots
trigger(required) - Trigger content (hover/focus target).inner_block(required) - Hover card content.