TheDocumentation 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.
anchor-size() CSS function lets you size an element based on the dimensions of its anchor. This plugin exposes it through a family of utilities that follow the pattern {size-property}-anchor{-anchor-size?}/{name?}. They are useful whenever you want a tooltip, popover, or other floating element to match or proportion itself against the element it is anchored to — without hardcoding sizes or writing custom CSS.
Covered size properties
The utility prefix maps to a CSS sizing property:| Prefix | CSS property |
|---|---|
w-anchor | width |
h-anchor | height |
min-w-anchor | min-width |
min-h-anchor | min-height |
max-w-anchor | max-width |
max-h-anchor | max-height |
Anchor size values
An optional suffix after-anchor specifies which dimension of the anchor to read. When the suffix is omitted, the function uses the same dimension as the property being set (for example, w-anchor reads the anchor’s width):
| Utility suffix | anchor-size() argument | Reads |
|---|---|---|
| (none) | (empty / implicit) | same dimension as the property |
-width | width | anchor’s inline width |
-height | height | anchor’s block height |
-block | block | anchor’s block size |
-inline | inline | anchor’s inline size |
-self-block | self-block | anchored element’s own block size |
-self-inline | self-inline | anchored element’s own inline size |
When you omit the anchor size suffix, the browser uses the dimension that matches the CSS property.
w-anchor is equivalent to width: anchor-size(width) and h-anchor is equivalent to height: anchor-size(height). This is the shortest way to match an element’s size to its anchor.Basic usage
Match the floating element’s width to the anchor’s width:Cross-dimension sizing
You can read a different anchor dimension than the one you are setting. This is useful for creating square elements that match the anchor’s height, or for other proportional relationships:Named anchor modifier
Like theanchor() utilities, you can target a specific anchor by adding a /name modifier instead of relying on the implicit position-anchor.
Non-dashed ident — prefixed with --tw-anchor_:
Offsets and negative values
Append any Tailwind spacing value to compute a size with acalc() offset. Negative values are supported:
Related
anchor() functions
Explicit edge-to-edge positional placement with anchor().
Utility index
Full list of every utility provided by this plugin.