Skip to main content

Carousel

show code
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { Carousel, CarouselArrows, Image, useCarousel } from "mui-eazy";
import { imgeList } from "./data";
// ----------------------------------------------------------------------
export default function MarketingCaseStudyDetailsGallery() {
const slides = imgeList.map((slide) => ({
src: slide,
}));

const carousel = useCarousel(
slides.length > 5
? {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 5,
slidesToScroll: 1,
}
: {
centerMode: true,
slidesToShow: slides.length,
},
);

return (
<>
<Stack
direction="row"
justifyContent="space-between"
sx={{ mt: 3, mb: 5 }}
>
<Typography variant="h4">Gallery</Typography>
<CarouselArrows
spacing={2}
onNext={carousel.onNext}
onPrev={carousel.onPrev}
/>
</Stack>

<Carousel ref={carousel.carouselRef} {...carousel.carouselSettings}>
{slides.map((slide, index) => (
<Box key={index} sx={{ px: 1 }}>
<Box
sx={{
borderRadius: 2,
overflow: "hidden",
cursor: "pointer",
}}
>
<Image
sx={{
height: "165px",
}}
alt={slide.src}
src={slide.src}
ratio="16/9"
/>
</Box>
</Box>
))}
</Carousel>
</>
);
}

Props

tip
  • Type: any, can be customized as needed.
  • Default value:
    • Not specified: optional.
    • Specified as "require": mandatory.
  • Type link: Click to navigate to the details below.
OptionTypeDefaultDescription
refrefdom ref
slidesToShownumberthe sum of cards to show
slidesToScrollnumberthe num of cards to carousel by one step
speednumberspeed of carousel
infinitebooleanloop carousel

Type