You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

embla-carousel-react-component-test

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

embla-carousel-react-component-test

An easy-to-use carousel component based on Embla Carousel for React.

0.1.2
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

An easy-to-use carousel component based on Embla Carousel for React.

  • Motivation
  • Installation
  • Basic Usage
  • Component API
  • Examples
  • License

Motivation

Embla Carousel is completedly unopinionated about the way you styles the carousels, including the slide container's layout. If you want to reuse the carousels with a different number of slides per view, redeclaration of the container's style is needed, which's not optimal for reusability.

To solve the problem, the component comes with minimal styles needed to layout the container.

Note that the component only covers some common use cases. If you want to achieve extraordinary stuffs with Embla Carousel's internal API, you need to implement yourself.

Installation

To get started, install the component via npm or yarn:

npm install embla-carousel-react-component-test
yarn add embla-carousel-react-component-test

Basic Usage

import Carousel from 'embla-carousel-react-component-test';

<Carousel perView={1} className='mt-4'>
  {[...Array(5).keys()].map((n) => (
    <Carousel.Slide key={n}>
      <div className='h-40 w-full rounded-md bg-slate-300 p-4'>
        Slide {n + 1}
      </div>
    </Carousel.Slide>
  ))}
</Carousel>;

View all the examples

Component API

PropTypeDefaultDescription
perViewnumberrequiredThe number of slides per view
gapstring1remThe spacing between slides
optionsEmblaOptionsTypeSee hereEmbla Carousel's options
pluginsEmblaPluginType[]Embla Carousel's plugins
PrevButton() => JSX.ElementPrevious Button component
NextButton() => JSX.ElementNext Button component
Dots() => JSX.ElementDot Indicators component
Thumbs() => JSX.ElementThumbs component
containerStyleReact.CSSPropertiesSee hereCustomize the container's style. To use this prop, remove perView first

options

The component comes with a few opinionated options to ensure it works properly out of the box.

{
  align: 'start',
  slidesToScroll: 'auto',
  containScroll: 'trimSnaps'
}

You can overwrite this by providing your own options.

containerStyle

The component use grid to layout the container.

{
  display: 'grid',
  gridAutoFlow: 'column',
  gridAutoColumns: perView ? `${100 / perView}%` : '100%',
}

You can overwrite this by providing your own styles.

Carousel.PrevButton, Carousel.NextButton

PropTypeDefaultDescription
disabledClassNamestringdisabledClassName for disabled state

The components also expose a data-disabled attribute that you can use to conditionally apply different styles.

Carousel.Dots

PropTypeDefaultDescription
selectedClassNamestringselectedClassName for selected state
nonSelectedClassNamestringClassName for non-selected state (Tailwind CSS users may need this)

The component also exposes a data-selected attribute that you can use to conditionally apply different styles.

Carousel.Thumbs

PropTypeDefaultDescription
perViewnumberrequiredThe number of thumbs per view
gapstring1remThe spacing between thumbs

Carousel.Thumb

PropTypeDefaultDescription
indexnumberrequiredThe index of thumb item
selectedClassNamestringselectedClassName for selected state
nonSelectedClassNamestring1remClassName for non-selected state (Tailwind CSS users may need this)

The component also exposes a data-selected attribute that you can use to conditionally apply different styles.

Examples

Basic

Plugins

License

MIT

Keywords

slider

FAQs

Package last updated on 02 Feb 2023

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