Skip to content

Set horizontal offset position for tooltip #966

Answered by gabrieljablonski
shmoeaz asked this question in Q&A
Discussion options

You must be logged in to vote

You can set the floating-ui middlewares manually to achieve this.
The main thing is using the offset() middleware with the crossAxis options.

Here's an example.

<Tooltip
  id="my-tooltip"
  middlewares={[
    // change `crossAxis`
    offset({ mainAxis: 10, crossAxis: 50 }),
    flip(),
    shift({ padding: 5 }),
  ]}
/>

The other middlewares are there to keep the other tooltip positioning rules the same, since passing a value to middlewares overrides the defaults.

Check the floating-ui docs for more info.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shmoeaz
Comment options

Answer selected by gabrieljablonski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants