All Projects → brainhubeu → React Carousel

brainhubeu / React Carousel

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Carousel

Monitaure
🔔 A server uptime monitoring progressive web application - NO LONGER MAINTAINED
Stars: ✭ 135 (-82.33%)
Mutual labels:  webpack, jest, sass
Iceberg
Front-End Boilerplate built with React + Babel + Webpack + SASS
Stars: ✭ 144 (-81.15%)
Mutual labels:  webpack, jest, sass
100 Days Of Code Frontend
Curriculum for learning front-end development during #100DaysOfCode.
Stars: ✭ 2,419 (+216.62%)
Mutual labels:  webpack, jest, sass
React Typescript Web Extension Starter
🖥 A Web Extension starter kit built with React, TypeScript, SCSS, Storybook, Jest, EsLint, Prettier, Webpack and Bootstrap. Supports Google Chrome + Mozilla Firefox + Brave Browser 🔥
Stars: ✭ 510 (-33.25%)
Mutual labels:  webpack, jest
Ts Monorepo
Template for setting up a TypeScript monorepo
Stars: ✭ 459 (-39.92%)
Mutual labels:  webpack, jest
Laravel Vue Boilerplate
🐘 A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.
Stars: ✭ 472 (-38.22%)
Mutual labels:  jest, sass
Adminkit
🧰 AdminKit is a free & open source Bootstrap 5 Admin Template
Stars: ✭ 395 (-48.3%)
Mutual labels:  webpack, sass
Webpack Starter Basic
A simple webpack starter project for your basic modern web development needs.
Stars: ✭ 552 (-27.75%)
Mutual labels:  webpack, sass
Naomi
Sublime Text enhanced syntax highlighting for JavaScript ES6/ES7/ES2015/ES2016/ES2017+, Babel, FlowType, React JSX, Styled Components, HTML5, SCSS3, PHP 7, phpDoc, PHPUnit, MQL4. Basic: Git config files.
Stars: ✭ 544 (-28.8%)
Mutual labels:  webpack, sass
Hooper
🎠 A customizable accessible carousel slider optimized for Vue
Stars: ✭ 561 (-26.57%)
Mutual labels:  carousel, slide
React Webpack Typescript Starter
Minimal starter with hot module replacement (HMR) for rapid development.
Stars: ✭ 632 (-17.28%)
Mutual labels:  webpack, sass
Skplayer
🎵 A simple & beautiful HTML5 music player
Stars: ✭ 437 (-42.8%)
Mutual labels:  webpack, sass
Cc
一个基于angular5.0.0+ng-bootstrap1.0.0-beta.8+bootstrap4.0.0-beta.2+scss的后台管理系统界面(没基础的同学请先自学基础,谢谢!)
Stars: ✭ 416 (-45.55%)
Mutual labels:  webpack, sass
Angular Electron
Ultra-fast bootstrapping with Angular and Electron (Typescript + SASS + Hot Reload) 🚤
Stars: ✭ 4,914 (+543.19%)
Mutual labels:  webpack, sass
Webpack Boilerplate
A minimal webpack 5 boilerplate with only Babel, SASS and lodash (optional) on board
Stars: ✭ 404 (-47.12%)
Mutual labels:  webpack, sass
Ngx Admin
Customizable admin dashboard template based on Angular 10+
Stars: ✭ 23,286 (+2947.91%)
Mutual labels:  webpack, sass
Retro Board
Retrospective Board
Stars: ✭ 622 (-18.59%)
Mutual labels:  webpack, jest
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (-15.05%)
Mutual labels:  webpack, sass
Public
Repository for wallaby.js questions and issues
Stars: ✭ 662 (-13.35%)
Mutual labels:  webpack, jest
Js Stack From Scratch
🛠️⚡ Step-by-step tutorial to build a modern JavaScript stack.
Stars: ✭ 18,814 (+2362.57%)
Mutual labels:  webpack, jest


react-carousel

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

Live code demo | v1 migration guide | Hire us

CircleCI Last commit license PRs Welcome Renovate enabled

Coveralls github Downloads Activity Minified npm Contributors

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 to inputs), 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 recommend Next.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).

import dynamic from '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.

import React from 'react';
import Carousel from '@brainhubeu/react-carousel';
import '@brainhubeu/react-carousel/lib/style.css';

const MyCarousel = () => (
  <Carousel plugins={['arrows']}>
    <img src={imageOne} />
    <img src={imageTwo} />
    <img src={imageThree} />
  </Carousel>
);

export default MyCarousel;

gif

Showing dots or thumbnails

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

import Carousel, { Dots } from '@brainhubeu/react-carousel';
import '@brainhubeu/react-carousel/lib/style.css'; import { useState } from 'react';

const MyCarouselWithDots = () => {
  const [value, setValue] = useState(0);

  const onChange = value => {
  setValue(value);
  }

  return (
    <div>
      <Carousel
        value={value}
        onChange={onChange}
      >
        <img className="img-example" src={someImage} />
        ...
        <img className="img-example" src={anotherImage} />
      </Carousel>
      <Dots
        value={this.state.value}
        onChange={this.onChange}
        thumbnails={[
          (<img key={1} className="img-example-small" src={abstractImage} />),
          ...
          (<img key={12} className="img-example-small" src={transportImage} />),
        ]}
      />
    </div>
  );
};

export default MyCarouselWithDots;

gif

Props

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

Carousel props

Prop Type Default Description
value Number undefined Current slide's index (zero based, depends on the elements order)
onChange Function undefined Handler triggered when current slide is about to change (e.g. on arrow click or on swipe)
slides Array undefined Alternative way to pass slides. This prop expects an array of JSX elements
itemWidth Number undefined Determines custom width for every slide in the carousel
offset Number 0 Padding between items
animationSpeed Number 500 Determines transition duration in milliseconds
draggable Boolean true Makes it possible to drag to the next slide with mouse cursor
breakpoints Object undefined All 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

Prop Type Default Description
value Number slide position in the slides Array Current Carousel value
onChange Function undefined onChange callback (works the same way as onChange in Carousel component)
number Number Amount of slides Number of slides in the carousel you want to control
thumbnails Array of ReactElements undefined Array of thumbnails to show. If not provided, default dots will be shown
rtl Boolean false Indicating 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
  • open http://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

See the Workflow subsection in our docs

Labels

See the Labels subsection in our docs

Decision log

See the Decision log subsection in our docs

License

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

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 teammates here.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].