Tooltip

A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

Features

  • Provider to control display delay globally.
  • Opens when the trigger is focused or hovered.
  • Closes when the trigger is activated or when pressing escape.
  • Supports custom timings.

Installation

Install the component from your command line.

cargo add radix-yew-tooltip

Anatomy

Import all parts and piece them together.

use radix_yew_tooltip::*;
use yew::prelude::*;

#[component]
fn Anatomy() -> Html {
    html! {
        <TooltipProvider>
            <Tooltip>
                <TooltipTrigger />
                <TooltipPortal>
                    <TooltipContent>
                        <TooltipArrow />
                    </TooltipContent>
                </TooltipPortal>
            </Tooltip>
        </TooltipProvider>
    }
}

API Reference

Provider

Wraps your app to provide global functionality to your tooltips.

PropTypeDefault
delay_durationi32700
skip_delay_durationi32300
disable_hoverable_contentOption<bool>-

Root

Contains all the parts of a tooltip.

PropTypeDefault
default_openOption<bool>-
openOption<bool>-
on_open_changeCallback<bool>-
delay_durationOption<i32>-
disable_hoverable_contentOption<bool>-

Trigger

The button that toggles the tooltip. By default, the TooltipContent will position itself against the trigger.

PropTypeDefault
as_childCallback<TooltipTriggerChildProps, Html>-
Data attributeValues
[data-state]"closed" | "delayed-open" | "instant-open"

Portal

When used, portals the content part into the body.

PropTypeDefault
force_mountOption<bool>-
containerOption<web_sys::Element>-
container_refOption<NodeRef>-

Content

The component that pops out when the tooltip is open.

PropTypeDefault
as_childOption<Callback<TooltipContentChildProps, Html>>-
on_escape_key_downCallback<KeyboardEvent>-
on_pointer_down_outsideCallback<PointerDownOutsideEvent>-
force_mountOption<bool>-
sideSideSide::Top
side_offsetf640.0
alignAlignAlign::Center
align_offsetf640.0
avoid_collisionsbooltrue
collision_boundaryVec<web_sys::Element>vec![]
collision_paddingPaddingPadding::All(0.0)
stickyStickySticky::Partial
hide_when_detatchedboolfalse
Data attributeValues
[data-state]"closed" | "delayed-open" | "instant-open"
[data-side]"left" | "right" | "bottom" | "top"
[data-align]"start" | "end" | "center"
CSS VariableDescription
--radix-tooltip-content-transform-originThe transform-origin computed from the content and arrow positions/offsets.
--radix-tooltip-content-available-widthThe remaining width between the trigger and the boundary edge.
--radix-tooltip-content-available-heightThe remaining height between the trigger and the boundary edge.
--radix-tooltip-trigger-widthThe width of the trigger.
--radix-tooltip-trigger-heightThe height of the trigger.

Arrow

An optional arrow element to render alongside the tooltip. This can be used to help visually link the trigger with the TooltipContent. Must be rendered inside TooltipContent.

PropTypeDefault
as_childOption<Callback<TooltipArrowChildProps, Html>>-
widthf6410.0
heightf645.0

Examples

TODO

Accessibility

Keyboard Interactions

KeyDescription
TabOpens/closes the tooltip without delay.
SpaceIf open, closes the tooltip without delay.
EnterIf open, closes the tooltip without delay.
EscapeIf open, closes the tooltip without delay.

Custom APIs

TODO

See Also