megos / react-swipeable-scroll-snap-carousel

A tiny swipeable carousel built with scroll snap for React

Home Page:https://megos.github.io/react-swipeable-scroll-snap-carousel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-swipeable-scroll-snap-carousel

A tiny swipeable carousel built with scroll snap for React

Features

  • Carousel by scroll-snap-type
  • Swipeable by mouse event
  • programmatically changed index

Getting Started

npm install react-swipeable-scroll-snap-carousel
import React, { useState } from 'react'
import { Carousel } from 'react-swipeable-scroll-snap-carousel'

function App() {
  const [index, setIndex] = useState(0)
  return (
    <Carousel index={index} onChangeIndex={setIndex}>
      <div style={{ backgroundColor: 'pink' }}>1</div>
      <div style={{ backgroundColor: 'skyblue' }}>2</div>
    </Carousel>
  )
}

About

A tiny swipeable carousel built with scroll snap for React

https://megos.github.io/react-swipeable-scroll-snap-carousel/

License:MIT License


Languages

Language:TypeScript 92.3%Language:HTML 7.7%