Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Is it possible to customize the reference element in React Popper?

I am using React Popper to position an element relative to another. I have set up some basic code, to provide the starting structure.

export default function App() {
  const [containerRef, setContainerRef] = useState(null);
  const [tooltipRef, setTooltipRef] = useState(null);

  const {
    styles: { popper },
    attributes: { popper: popperAttributes }
  } = usePopper(containerRef, tooltipRef, {
    placement: "bottom-start"
  });

  return (
    <>
      <div className="container" ref={setContainerRef}>
        Content
      </div>
      <span
        ref={setTooltipRef}
        className="tooltip"
        style={{ ...popper }}
        {...popperAttributes}
      >
        Tooltip
      </span>
    </>
  );
}

I have added some styles too, just to see the elements.

.container {
  display: flex;
  align-items: center;
  padding: 0 20px;
  background-color: rgb(255, 121, 121);
  height: 30px;
  border: 1px solid #000;
}

.tooltip {
  width: 100%;
  background-color: #333;
  width: 100%;
  color: #fff;
}

Ok, as you can see, the container has a red-ish background color. What I want though, is, if the tooltip is positioned at the top, I want the container's background to be yellow. Is that possible in React Popper?

Here is the full code. https://codesandbox.io/s/sad-cartwright-r6oyrb

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!