When an anchored element’s default position would push it outside the viewport or its containing block, the browser can automatically try alternative placements usingDocumentation 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.
position-try-fallbacks. The try-* utilities set the list of fallbacks to attempt, and try-order-* controls the order in which they are evaluated. Together they let you build tooltips, dropdowns, and context menus that intelligently reposition themselves without any JavaScript.
Controlling fallback order with try-order-*
Before the browser tests each fallback, you can influence which fallback wins by setting an ordering strategy.
try-order-normal
Try each fallback in the order it appears in the position-try-fallbacks list. This is the default.
try-order-w
Among all valid fallback positions (those that fit without overflow), prefer the one that gives the anchored element the most available width.
try-order-h
Prefer the fallback that gives the anchored element the most available height.
Setting fallbacks with try-*
try-none
Remove all fallbacks. The anchored element stays at its default position even if it overflows.
Flip utilities
The flip utilities generate the standard CSS keyword fallbacks for common mirroring patterns.| Utility | CSS value | Effect |
|---|---|---|
try-flip-x | flip-inline | Mirror horizontally |
try-flip-y | flip-block | Mirror vertically |
try-flip-s | flip-start | Mirror along writing-mode start axis |
try-flip-all | flip-block, flip-inline, flip-block flip-inline | Try vertical, horizontal, and diagonal flips |
Position area fallbacks
Anyposition-area value can be used as a fallback directly. The utility names match the anchored-* positioning utilities. Each try-* class sets position-try-fallbacks to that single value:
position-try-fallbacks declaration, use the arbitrary value syntax with a comma-separated list:
Arbitrary values
For custom fallback lists or values not covered by the preset utilities:Example: tooltip with automatic repositioning
The following tooltip starts below its trigger but flips above it when there is not enough space below, and also tries diagonal positions as a last resort.flip-block (above the button), then flip-inline (mirrored horizontally), then both — and picks whichever gives the most height.
Related
Position visibility
Hide the anchored element when no fallback fits the viewport.
position-area utilities
The full list of position-area values available as fallback targets.