How to prevent the tooltip from overlapping the navigation bar? #1135
-
By default, the tooltip's position will be at the top. However, this will be overriden when its size is greater than that of the visible area. For example, if it is too close to the top of the page and rendering it would cause it to clip outside of the bounds of the viewport it will be rendered at the bottom instead. I have a navigation bar fixed to the top of my page and would like the tooltip's abovementioned behavior to account for its size, thus, rendering at the bottom when it detects it will overlap the navigation bar, e.g., |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
As mentioned in #1127, you can customize the Maybe something like this might work, please let me know. import { offset, flip } from '@floating-ui/dom'
<Tooltip
middlewares={[offset(10), flip({ padding: 50 })]}
/> |
Beta Was this translation helpful? Give feedback.
By default, the tooltip also uses the
shift()
middleware, which I didn't include. This should fix the issue with the margin.As for your question about top padding, while I do understand what you mean, it doesn't exactly make sense in this case since that's not how the overflow works. I believe it should work as-is for your use case, but if not, try reading the
floating-ui
docs and see if there's anything there that might help you.