React-popper: Rendering an arrow and stying, with referenceElement

Created on 23 Aug 2018  路  8Comments  路  Source: popperjs/react-popper

Steps to reproduce the problem

  1. I'm trying to reproduce a tooltip-like behavior, with a referenceElement. My code is the following:
<Popper
    referenceElement={element}
    placement='right'
>
    {({ ref, style, placement, arrowProps }) => (
        <div ref={ref} style={style} data-placement={placement}>
            Popper element
            <div ref={arrowProps.ref} style={arrowProps.style} />
        </div>
    )}
</Popper>
  1. In the page, the "tooltip" is on the right from the DOM element, but with no arrow.
  2. If I would like the arrow to be shown and be pointed to the element at all placement he get, and also style the "tooltip" itself, how can I do that?

What is the expected behavior?
Tooltip should show an arrow beside him.

What went wrong?
He doesn't.

Packages versions
react-popper: 1.0.2

Code
https://codesandbox.io/s/r0lrlk54qp

no issue template

All 8 comments

Sorry I really need the codepen/codesandbox repro, otherwise I can't help you.

You have to style your arrow to make it visible somehow. Take a look at the demo page to see an example.

https://codesandbox.io/s/qkzk25lj8j

So to style its position for the tooltip I need to condition-style the arrow?

Meaning the direction the arrow is pointing at.

react-popper only provides the left or top offset of the arrow, all the styling is deferred to the consumer.

And is there a way to use the already made Arrow component so I wouldn't have to handle the direction the arrow is pointing?
Or that if I want to use the 'referenceElement' prop, I have to manually design and implement the arrow myself?

You can copy the one of the demo, but the library doesn't provide any style except for the positions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nstepien picture nstepien  路  5Comments

souporserious picture souporserious  路  5Comments

0xdevalias picture 0xdevalias  路  6Comments

souporserious picture souporserious  路  5Comments

craigsketchley picture craigsketchley  路  3Comments