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

168
Views
White space between slides in component carousel

I created a component carousel, everything is working fine but the second slide has unnecessary white space on top of it. How can I remove this? I've tried inspecting the website to find a possible solution, but the carousel always takes up the same amount of space. On the second slide though, it adds white space on top of it without increasing the size of the container. First Slide

Second slide Carousel.js:

const Carousel = ({ children }) => {
  const [activeIndex, setActiveIndex] = useState(0);

  const updateIndex = (newIndex) => {
    if (newIndex < 0) {
      newIndex = 0;
    } else if (newIndex >= React.Children.count(children)) {
      newIndex = React.Children.count(children) - 1;
    }
    setActiveIndex(newIndex);
  };

  return (
    <div className="overflow-hidden h-screen relative">
      <div
        className="whitespace-nowrap"
        style={{
          transform: `translateX(-${activeIndex * 100}%)`,
          transition: "transform 0.3s",
        }}
      >
        {React.Children.map(children, (child, index) => {
          return React.cloneElement(child, { width: "100%" });
        })}
      </div>
      <div className="flex justify-center absolute z-50 bottom-0">
        <button
          className="m-1 z-50"
          onClick={() => updateIndex(activeIndex - 1)}
        >
          Prev
        </button>
        <button
          className="m-1 z-50"
          onClick={() => updateIndex(activeIndex + 1)}
        >
          Next
        </button>
      </div>
    </div>
  );
};

CarouselItem.js:

const CarouselItem = ({ children, width }) => {
  return (
    <div
      className="inline-flex items-center justify-center h-screen bg-green-600 text-white"
      style={{ width: width }}
    >
      {children}
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza
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!