New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

styled-components-carousel

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled-components-carousel

A simple React Carousel component written in Typescript and built with [styled-components](https://github.com/styled-components/styled-components) using React Hooks.

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

A simple React Carousel component written in Typescript and built with styled-components using React Hooks.

Heavily inspired by react-slick with a simplified API and small behaviour changes.

Alt Text

Getting Started

Prerequisites

This component expects that you will have the following packages installed:

Installation

NPM

npm install styled-components-carousel

Yarn

yarn add styled-components-carousel

Examples

Basic Usage

import Carousel from 'styled-components-carousel';

const Example = () => (
    <Carousel
        center
        infinite
        showArrows
        showIndicator
        slidesToShow={3}
    >
        <div>
            <span>1</span>
        </div>
        <div>
            <span>2</span>
        </div>
        <div>
            <span>3</span>
        </div>
    </Carousel>
);

Breakpoints Usage

You can define custom settings per breakpoint for truly responsive behaviour.

import Carousel from 'styled-components-carousel';

const Example = () => (
    <Carousel
        slidesToShow={3}
        center
        centerPadding={30}
        breakpoints={[
            {
                size: 200,
                settings: {
                    slidesToShow: 1,
                    showArrows: false,
                    showIndicator: false,
                    swipeable: true,
                },
            },
            {
                size: 600,
                settings: {
                    slidesToShow: 3,
                    showArrows: false,
                    showIndicator: true,
                    swipeable: true,
                },
            },
            {
                size: 1000,
                settings: {
                    slidesToShow: 4,
                    showArrows: true,
                    showIndicator: true,
                    center: true,
                    swipeable: true,
                },
            },
        ]}
    >
        <div>
            <span>1</span>
        </div>
        <div>
            <span>2</span>
        </div>
        <div>
            <span>3</span>
        </div>
    </Carousel>
);

Props

PropTypeRequiredDescriptionDefault
centerbooleanNoShould the items be centered?False
infinitebooleanNoShould the carousel infinitely scroll the itemsFalse
showIndicatorbooleanNoShould the bottom item indicator be shown?True
showArrowsbooleanNoShould the side navigation arrows be shown?True
swipeablebooleanNoIs the carousel swipeable?True
debugbooleanNoA dev helper prop for debugging developmentFalse
slidesToShownumberNoThe number of slides to show at once.1
scaleOnFocusnumberNoHow much should the focused item scale?1
centerPaddingnumberNoUsed in conjunction with center property to adding padding to center card0
breakpointsarrayNoAn array of settings in order to have responsive behaviour for different screen sizesundefined

Development

Storybook

yarn storybook

Run tests

yarn test

Build

yarn build

RoadMap (open to feature requests)

  • Accessibility support
  • Custom slide animation
  • Custom arrow component
  • Custom indicator component
  • Vertical track

Keywords

carousel

FAQs

Package last updated on 08 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts