I trying to create a carrousel component that would take 100% width & height of a parent container (it should be able to go fullscreen). I have added a custom-arrow but I can't style it.
How to achieve such a result?
Here is my code and a sandbox:
const ArrowLeft = (props) => (
<button style={{background:"red", border: 0}} {...props} className={'prev'}>
back
</button>
);
const settings = {
dots: true,
infinite: true,
speed: 1000,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
lazyLoad: true,
centerMode: true,
adaptiveHeight: true,
fade: true,
arrows: true,
prevArrow: <ArrowLeft />,
autoplaySpeed: 5000,
className: "slides"
};
const images = [
"https://static.toiimg.com/photo/72975551.cms",
"https://www.gettyimages.fr/gi-resources/images/500px/983794168.jpg",
"https://www.freedigitalphotos.net/images/img/homepage/394230.jpg"
];
const StyledSlider = styled(Slider)``;
const Image = styled.div`
background-size: cover;
background: ${(props) => `url(${props.src}) no-repeat center`};
width: 100%;
height: 500px; // how to add an auto 100% width?
`;
export default function App() {
return (
<StyledSlider {...settings}>
{images.map((image, i) => {
return (
<div key={i}>
<Image src={image} alt="img" />
</div>
);
})}
</StyledSlider>
);
}
https://codesandbox.io/s/cranky-noether-1hdhr?file=/src/App.js
Any help would be greatly appreciated!