Tooltip Glossary
Define terms inside a paragraph, with a tooltip on each term. Each term is an inline button with data-sv-tooltip, and trigger="hover focus click" also opens the definition on tap.
A tooltip is attached to an and rendered in the through the API, so no parent can clip it.
Code
The following example assumes that you have imported the component and set up the theme.
<p class="glossary-text">13 collapsed lines
A tooltip is attached to an <button type="button" aria-describedby="tooltip-anchor" data-sv-tooltip="tooltip-anchor"> anchor element </button> and rendered in the <button type="button" aria-describedby="tooltip-top-layer" data-sv-tooltip="tooltip-top-layer"> top layer </button> through the <button type="button" aria-describedby="tooltip-popover" data-sv-tooltip="tooltip-popover"> popover </button> API, so no parent can clip it.</p>
<sv-tooltip id="tooltip-anchor" trigger="hover focus click">1 collapsed line
The element the tooltip describes, points at, and follows</sv-tooltip><sv-tooltip id="tooltip-top-layer" trigger="hover focus click">1 collapsed line
A browser layer above the page that ignores stacking contexts</sv-tooltip><sv-tooltip id="tooltip-popover" trigger="hover focus click">1 collapsed line
The platform API for content that shows above everything else</sv-tooltip>
<style>21 collapsed lines
.glossary-text { max-inline-size: 34rem; margin: auto; line-height: 1.7;
button { display: inline; padding: 0; font: inherit; color: var(--sv-gray-1); cursor: help; background: none; border: none; border-block-end: 1px dotted var(--sv-gray-3); } }
sv-tooltip { max-inline-size: 30ch; font-size: 0.875em; }</style>