2.1.1 • Published 3 months ago

@maker-ui/carousel v2.1.1

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
3 months ago

@elements-ui/carousel

An accessible carousel component built with react-spring that works seamlessly with a Theme UI theme provider or an Elements UI layout.

Installation

npm i @elements-ui/carousel

Usage

Carousel does not make any assumptions about the data you want to cycle through (text, photos, videos, etc.). Simply build your own custom template component and iterate over an array of data.

You can style your carousel with the sx prop as well as variants or classNames (see below).

import React from 'react'
import { ThemeProvider } from 'theme-ui'
import Carousel from '@elements-ui/carousel'

import theme from './theme'

const slideData = [
  { message: 'hi', class: '1' },
  { message: 'hiya', class: '2' },
  { message: 'hello', class: '3' },
]

const Slide = ({ message, class }) => <div className={class}>{message}</div>

export default () => (
  <ThemeProvider theme={theme}>
    <Carousel
      data={slideData}
      template={<Slide />}
      autoPlay
      duration={4500}
      transition="fade"
    />
  </ThemeProvider>
)

Props

PropsTypeDefaultDescription
dataarrayan array of objects to iterate over.
templateReact componentnull (required)a custom component that Carousel uses to create its slides. Each property of your data object should correspond with a prop in your custom component.
autoPlayboolfalsewhen set to true, Carousel will automatically cycle through slides based on the duration prop
durationnumber5000the duration in milliseconds that a slide will be visible. 5000 = 5 seconds
navbooltrueshows / hides accessible slide navigation (previous / next arrow buttons). You can customize these buttons with the arrow prop.
pageIndicatorboolfalseshows / hides a current slide indicator
transitionstring"slide"determines the slide enter / exit transition. Current options: "fade", "fade-up", "fade-down", "slide"
hoverPauseboolfalsepauses the carousel's autoPlay feature onMouseEnter and resumes onMouseLeave.
pauseboolfalsePauses the carousel's autoPlay feature. Helpful for designing slides in development or using with a custom control.
arrowReact componentnulloverrides the default arrow icon for slide navigation. Submit a right facing arrow component for next and the Carousel will rotate it 180 degrees for previous
variantstring"carousel"a custom Theme UI variant for styling. Recommended: use the default carousel variant.

Styling

Carousel supports both Theme UI variants as well as CSS selectors so you can customize the appearance of your design in any way.

ComponentDefault variantDefault className
Carousel (container)carouselcarousel
Pagination (container)carousel.paginationcarousel-pagination
Page Indicatorcarousel.pagecarousel-page (with active when current index)
Next Buttoncarousel.nextcarousel-next
Prev Buttoncarousel.prevcarousel-prev
2.1.1

3 months ago

2.1.0

5 months ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.2

2 years ago

0.4.3

3 years ago