SutraUI.Tooltip (Sutra UI v0.4.0)
View SourceA popup that displays information related to an element when hovered.
Supports dynamic positioning that automatically adjusts based on viewport boundaries to prevent the tooltip from being clipped.
Examples
<.tooltip id="add-btn-tip" tooltip="Add to library">
<button class="btn">Hover me</button>
</.tooltip>
<.tooltip id="right-tip" tooltip="Right side tooltip" side="right">
<button class="btn">Right</button>
</.tooltip>
<.tooltip id="auto-tip" tooltip="Auto-positions based on space" side="auto">
<button class="btn">Smart Position</button>
</.tooltip>Accessibility
- The tooltip is triggered by both hover and keyboard focus
- Adds
aria-describedbyon the wrapper around the trigger content - Uses
role="tooltip"on the tooltip content - For custom focusable triggers, put
aria-describedby={"#{id}-content"}on the focusable element when the description must be announced reliably - Note: Critical information should not be placed solely in tooltips
Summary
Functions
Renders a tooltip component.
Functions
Renders a tooltip component.
Attributes
id(:string) (required) - Unique identifier for the tooltip.tooltip(:string) (required) - The text content to display in the tooltip.side(:string) - The side to position the tooltip (auto for dynamic positioning). Defaults to"auto". Must be one of"top","bottom","left","right", or"auto".align(:string) - The alignment of the tooltip. Defaults to"center". Must be one of"start","center", or"end".class(:string) - Additional CSS classes. Defaults tonil.- Global attributes are accepted. Additional HTML attributes.
Slots
inner_block(required) - The element that triggers the tooltip on hover.