0.0.22 • Published 8 months ago

react-micro-carousel v0.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

React Micro Carousel

example workflow

bundlesize

Component features

  • Extremely small package size (gzipped):
    • Javascript: 2.6kB
    • CSS: 1.5kB
  • 0 external dependencies
  • Full typescript support
  • Built in with Tailwind, but you can always customize the styles
  • Handling touch/mouse events
  • Lazy image loading
  • Responsive support

Documentation

Simple react carousel docs

How to use:

If you are using Tailwind:

tailwind.config.ts

export default {
  content: [
    "./src/**/*.{js,ts,jsx,tsx}",
    "./node_modules/react-micro-carousel/**/*.js",
  ],
} satisfies Config;

...other way?

import 'react-micro-carousel/styles.min.css';

Components markup:

import {
  Carousel,
  CarouselProvider,
  Counter,
  DotsGroup,
  NextButton,
  PrevButton,
  Slide,
} from 'react-micro-carousel';

<CarouselProvider total={2}>
  <Carousel>
    <Slide>
      <img src="..." />
    </Slide>
    <Slide>
      <img src="..." />
    </Slide>
  </Carousel>

  <DotsGroup />
  <NextButton>Next<NextButton />
  <PrevButton>Prev</PrevButton>
</CarouselProvider>

Props documentation:

<CarouselProvider />

Component is used to initialize the carousel context with configuration options and wrap the other components.

PropTypeDefaultRequired
childrenReactNodeYes
slideHeightnumber0Yes
totalnumber0Yes
autoPlayDelaynumberfalseNo
slidesVisiblenumber1No
stepnumber1No
thresholdnumber0.25No
infinitebooleanfalseNo
disableTouchbooleanfalseNo
lazybooleantrueNo
autoPlaybooleanfalseNo

<Carousel />

A carousel that wraps the slides and provides the core functionality, such as scrolling to the next or previous slide.

PropTypeDefaultRequired
childrenReactNodeYes
wrapperClassNamestringNo
carouselClassNamestringNo

<Slide />

A single slide in a carousel.

PropTypeDefaultRequired
childrenReactNodeYes
indexnumberYes
classNamestringNo

<Dot />

A single dot.

PropTypeDefaultRequired
classNamestringNo
colorActivestringNo
colorInactivestringNo
indexnumberYes
disabledbooleanNo
onClickFunctionNo

<DotsGroup />

A component that renders a group of dots, representing the slides in the carousel. It provides auto generated dots for the carousel.

PropTypeDefaultRequired
classNamestringNo
dotClassNamestringNo
colorActivestringNo
colorInactivestringNo
onClickFunctionNo

<NextButton />

PropTypeDefaultRequired
classNamestringNo
childrenReactNodeYes
onClickFunctionNo

<PrevButton />

PropTypeDefaultRequired
classNamestringNo
childrenReactNodeYes
onClickFunctionNo

<Counter />

PropTypeDefaultRequired
classNamestringNo
0.0.22

8 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago