A
A
Alexander2021-06-22 23:08:52
React
Alexander, 2021-06-22 23:08:52

How to set styles for a class in styled components?

How to set styles for a class in styled components?
I want to style the swiper wrapper using the .heroSlider class, how can I do this without creating a component in styled components?

<Swiper
      wrapperTag='ul'
      className='heroSlider'
      allowTouchMove={false}
      speed={600}
    >
...
</Swiper>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Timoshenkov, 2021-06-23
@axrising

It all depends on what Swiper renders.
Well, or you can try to "throw" classes on the component:

const StyledSwiper = styled(Swiper)`
  // содержимое .heroSlider
`;

render(
  <StyledSwiper
      wrapperTag='ul'
      allowTouchMove={false}
      speed={600}
    >
    ...
  </Swiper>
);

Documentation:
  • https://styled-components.com/docs/basics#getting-...
  • https://styled-components.com/docs/basics#styling-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question