In this guide you will build a simple tooltip that appears below a button using the CSS Anchor Positioning API. You will define the button as an anchor, attach the tooltip to it, and then explore how to reposition the tooltip to different sides — all without any JavaScript or inline styles.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/toolwind/anchors/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Make sure you have installed and registered the plugin before following this guide. See installation if you have not done that yet.Step 1: Define an anchor
Use theanchor/{name} utility to register an element as an anchor. The name you provide is automatically converted to a valid CSS dashed ident under the hood.
Step 2: Attach and position the tooltip
Useanchored-{position}/{name} to attach an element to the anchor and specify where it should appear. The shorthand combines position-anchor and position-area in a single class.
:where() wrapper sets position: absolute and a view-transition-name at zero specificity, so you can override either property with a plain utility class like fixed without needing !important.
Step 3: Try different positions
Swap the position segment to move the tooltip to any side. All of the following use the same anchor name — only the placement changes.position-area value:
| Class | Generated CSS |
|---|---|
anchored-top-center | position-area: top center |
anchored-bottom-center | position-area: bottom center |
anchored-left-center | position-area: left center |
anchored-right-center | position-area: right center |
anchored-bottom-left | position-area: bottom left |
anchored-top-right | position-area: top right |
Full example
Here is the complete tooltip example with a bit of styling:The anchor and its anchored element do not need to be siblings or share a parent. The CSS Anchor Positioning API works across the DOM as long as both elements are in the same stacking context. The
relative wrapper above is only for the button’s own layout — not required by the plugin.Animate position changes with View Transitions
Everyanchored/{name} class automatically receives a view-transition-name. This means you can animate the tooltip moving from one position to another using the browser-native View Transitions API:
Next steps
Core utilities
Explore
anchor, anchored, and position-area utilities in depth.Anchor functions
Use
anchor() with offsets for pixel-precise placement.Position try
Add fallback positions so tooltips stay on screen near viewport edges.
Utility index
Full reference for every class the plugin generates.