Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)

License

NotificationsYou must be signed in to change notification settings

brainhubeu/react-carousel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



react-carousel

A pure extendable React carousel, powered byBrainhub (craftsmen who ❤️ JS)

Live code demo |v1 migration guide |Hire us

CircleCILast commitlicensePRs WelcomeRenovate enabled

Coveralls githubDownloadsActivityMinifiednpmContributors

Table of Contents

Why?

There are some great carousels (like slick) that do not have real React implementations. This library provides you with carousel that is not merely a wrapper for some jQuery solution, can be used as controlled or uncontrolled element (similar toinputs), and has tons of useful features.

Installation

Basic

npm i @brainhubeu/react-carousel

Typescript

npm i @types/brainhubeu__react-carousel -D

SSR

When using@brainhubeu/react-carousel with SSR (Server-side Rendering), we recommendNext.js as@brainhubeu/react-carousel currently doesn't work on the server side so it must be rendered on the client side (maybe we'll provide server-side working in the future).

importdynamicfrom'next/dynamic';const{default:Carousel, Dots}=dynamic(()=>require('@brainhubeu/react-carousel'),{ssr:false},);

Usage

By default, the component does not need anything except children to render a simple carousel.Remember that styles do not have to be imported every time you use carousel, you can do it once in an entry point of your bundle.

importReactfrom'react';importCarouselfrom'@brainhubeu/react-carousel';import'@brainhubeu/react-carousel/lib/style.css';constMyCarousel=()=>(<Carouselplugins={['arrows']}><imgsrc={imageOne}/><imgsrc={imageTwo}/><imgsrc={imageThree}/></Carousel>);exportdefaultMyCarousel;

gif

Showing dots or thumbnails

There is a separate Dots component that can be used to fully control navigation dots or add thumbnails.

importCarousel,{Dots}from'@brainhubeu/react-carousel';import'@brainhubeu/react-carousel/lib/style.css';import{useState}from'react';constMyCarouselWithDots=()=>{const[value,setValue]=useState(0);constonChange=value=>{setValue(value);}return(<div><Carouselvalue={value}onChange={onChange}><imgclassName="img-example"src={someImage}/>        ...<imgclassName="img-example"src={anotherImage}/></Carousel><Dotsvalue={this.state.value}onChange={this.onChange}thumbnails={[(<imgkey={1}className="img-example-small"src={abstractImage}/>),          ...(<imgkey={12}className="img-example-small"src={transportImage}/>),]}/></div>);};exportdefaultMyCarouselWithDots;

gif

Props

You can access a clickable demo with many examples and alive code editor by clicking on a Prop name.

Carousel props

PropTypeDefaultDescription
valueNumberundefinedCurrent slide's index (zero based, depends on the elements order)
onChangeFunctionundefinedHandler triggered when current slide is about to change (e.g. on arrow click or on swipe)
slidesArrayundefinedAlternative way to pass slides. This prop expects an array of JSX elements
itemWidthNumberundefinedDetermines custom width for every slide in the carousel
offsetNumber0Padding between items
animationSpeedNumber500Determines transition duration in milliseconds
draggableBooleantrueMakes it possible to drag to the next slide with mouse cursor
breakpointsObjectundefinedAll props can be set to different values on different screen resolutions

Plugins

You can extend react-carousel default behavior by applying plugins shipped within carousel

Plugins documentation

Dots props

PropTypeDefaultDescription
valueNumberslide position in the slides ArrayCurrentCarousel value
onChangeFunctionundefinedonChange callback (works the same way asonChange inCarousel component)
numberNumberAmount of slidesNumber of slides in the carousel you want to control
thumbnailsArray of ReactElementsundefinedArray of thumbnails to show. If not provided, default dots will be shown
rtlBooleanfalseIndicating if the dots should have direction from Right to Left

Setting up local development which means running the docs/demo locally:

  • git clone https://github.com/brainhubeu/react-carousel
  • cd react-carousel
  • yarn
  • yarn start-demo
  • openhttp://localhost:8000/

Tests

Each test command should be run from the root directory.

Unit tests

yarn test:unit:coverage

E2E tests

yarn test:e2e

Workflow

Seethe Workflow subsection in our docs

Labels

Seethe Labels subsection in our docs

Decision log

Seethe Decision log subsection in our docs

License

react-carousel is copyright © 2018-2020Brainhub. It is free software and may be redistributed under the terms specified in thelicense.

About

react-carousel is maintained by the Brainhub development team. It is funded by Brainhub and the names and logos for Brainhub are trademarks of Brainhub Sp. z o.o.. You can check other open-source projects supported/developed by our teammateshere.

Brainhub

We love open-source JavaScript software! See our other projects or hire us to build your next web, desktop and mobile application with JavaScript.

About

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors44


[8]ページ先頭

©2009-2025 Movatter.jp