Skip to content

fix(tooltip): keep tooltips out of the scrollable overflow - #4862

Open
pdanpdan wants to merge 2 commits into
saadeghi:masterfrom
pdanpdan:fix/tooltip-top-layer
Open

pdanpdan wants to merge 2 commits into
saadeghi:masterfrom
pdanpdan:fix/tooltip-top-layer

Conversation

@pdanpdan

@pdanpdan pdanpdan commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor
  • the bubble was absolutely positioned inside the trigger, so a closed tooltip still adds its width to every scroll ancestor
  • put the bubble and the arrow in position: fixed anchored to the trigger (anchor-name/anchor-scope on the trigger, anchor() insets per placement), so they no longer count toward the ancestor's scrollable overflow
  • anchor-scope is important - without it every bubble on the page resolves to the same trigger - so the new path is behind @supports (anchor-scope: --tip) and older browsers keep the current positioning
  • no position-try-fallbacks: the arrow is anchored to the trigger, so a flipped bubble would leave the arrow behind

example:
v1: https://play.tailwindcss.com/mihDD377RQ
v2: https://play.tailwindcss.com/KtQjZgV2QV - improve positioning, use only variables to keep all responsive

refs #4610, #4534

@github-actions

Copy link
Copy Markdown

1 component changed. Basic playground: Before vs. After.

- the bubble was absolutely positioned inside the trigger, so a closed tooltip still adds its width to every scroll ancestor
- put the bubble and the arrow in `position: fixed` anchored to the trigger (`anchor-name`/`anchor-scope` on the trigger, `anchor()` insets per placement), so they no longer count toward the ancestor's scrollable overflow
- `anchor-scope` is important - without it every bubble on the page resolves to the same trigger - so the new path is behind `@supports (anchor-scope: --tip)` and older browsers keep the current positioning
- no `position-try-fallbacks`: the arrow is anchored to the trigger, so a flipped bubble would leave the arrow behind

example: https://play.tailwindcss.com/mihDD377RQ

closes saadeghi#4534
refs saadeghi#4610
@pdanpdan
pdanpdan force-pushed the fix/tooltip-top-layer branch from 334380d to 0cc9847 Compare November 17, 2026 12:21
@github-actions

Copy link
Copy Markdown

1 component changed. Basic playground: Before vs. After.

- now both absolute and fixed positioning use the same ref point
- use only variables to determine position
- improve docs to explain custom variables

example: https://play.tailwindcss.com/KtQjZgV2QV
@github-actions

Copy link
Copy Markdown

1 component changed. Basic playground: Before vs. After.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant