I'm trying to make a carousel to display some images of projects I've done. I know there are a lot of react carousel components around, so does anyone know of one that will work well with gatsby-image?
I use react-slick
that is very good and I can make it work with Gatsby Image.
Example in a page :
import React from "react"
import { graphql } from "gatsby"
import Img from "gatsby-image"
import Slider from "react-slick"
import "slick-carousel/slick/slick.css"
import "slick-carousel/slick/slick-theme.css"
const settings = {
dots: false,
infinite: true,
autoplay: true,
}
const CarouselPage = ({ data }) => {
return (
<Slider {...settings} className="overflow-hidden">
<Img fluid={data.image1.childImageSharp.fluid} />
<Img fluid={data.image2.childImageSharp.fluid} />
</Slider>
)
}
export const query = graphql`
query {
image1: file(relativePath: { eq: "my-image-1-path.jpg" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
image2: file(relativePath: { eq: "my-image-2-path.jpg" }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
export default CarouselPage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With