Primitives
Tooltip
One line of text on the darkest surface in the language, so it reads over anything it lands on. The box is the language's; the coordinates are the consumer's.
Two contracts travel with the base class, and both come out of rule 4.
The element must be a child of <body> and never a child of the component it
annotates: position: fixed re-anchors to any transformed ancestor, and
rule 4 makes every hovered ancestor transformed, so the first hover would
move the tooltip with the thing it is pointing at. And it may never carry
information that exists nowhere else, because a keyboard or touch reader may
never see it. Measuring the trigger and setting left/top is the
consumer's half; gallery.js is the reference wiring.
--anchored is the other half of that trade. A tooltip belonging to exactly
one trigger can live inside it, and then position: absolute is what you
want: it measures from the transformed ancestor rather than fighting it, so a
hover lift carries the tooltip along instead of stranding it. The consumer
still supplies the offsets - a positioned trigger and the left/top the
placement needs - and the <body> contract does not apply.
--flow is the third placement: the box is laid out by whoever owns its
wrapper, and it positions itself not at all. A charting library is the case
that forces it - recharts places and transforms a wrapper and renders your
content inside it - and the base class deceives here, because a fixed box with
auto insets lands at its static position and so appears to work perfectly. It
scrolls with the chart only because that wrapper is transformed, which is the
containment the <body> contract exists to escape; set recharts' portal
prop and the positioning vanishes along with the failure's visibility.
--wrap is for a tooltip carrying a sentence instead of a reading. nowrap is
right for a value, which is harder to read broken across two lines than run
past its trigger, and wrong for prose; pair it with a width.
The box itself
Using --flow, which is what this example always needed: in a real page the base class is appended to <body> and positioned by script<span class="axi-tooltip axi-tooltip--flow" style="display: inline-block">Launching (inferred)</span>
Anchored, wrapping
Inside its trigger rather than appended to <body>, and carrying a sentence, so it takes both modifiers and a width<span style="position: relative; display: inline-block; padding: 6px 10px; border: 1px solid var(--axi-rule)">Coverage
<span class="axi-tooltip axi-tooltip--anchored axi-tooltip--wrap" style="left: 0; top: calc(100% + 6px); width: 180px">Share of the fight this player was alive and within range of the tag.</span>
</span>