FormidableLabs / nuka-carousel

Small, fast, and accessibility-first React carousel library with an easily customizable UI and behavior to fit your brand and site.
https://commerce.nearform.com/open-source/nuka-carousel
Other
3.08k stars 595 forks source link

Slide Buttons props #88

Closed kennetpostigo closed 8 years ago

kennetpostigo commented 8 years ago

Is there a prop to pass in to change the contents of the next and prev buttons? Wondering because by default those are the values of the buttons for the carousel.

Haven't used nuka-carousel before so I am not sure if I am overlooking how to change the button contents. I'm currently using a function component to render the carousel and props may be the best solution for this?

import React from 'react'
import Carousel from 'nuka-carousel';

function appCarousel (props) {
    return (
      <div className="UserSneakers">
        <Carousel slidesToShow={3} slidesToScroll={3} cellAlign="left">
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide1"/>
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide2"/>
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide3"/>
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide4"/>
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide5"/>
          <img src="http://placehold.it/400x400/ffffff/c0392b/&text=slide6"/>
        </Carousel>
      </div>
    )
};
export default appCarousel;
screen shot 2016-05-10 at 3 07 38 pm
charlesbodman commented 8 years ago

You want 'decorators' prop.

var decorators = [{
  component: React.createClass({
    render() {
      return (
        <button
          onClick={this.props.previousSlide}>
          Previous Slide
        </button>
      )
    }
  }),
  position: 'CenterLeft',
  style: {
    padding: 20
  }
},
{
  component: React.createClass({
    render() {
      return (
        <button
          onClick={this.props.nextSlide}>
          Next Slide
        </button>
      )
    }
  }),
  position: 'CenterRight',
  style: {
    padding: 20
  }
}
];

 <Carousel slidesToShow={3} slidesToScroll={3} cellAlign="left" decorators={decorators} >
     //Children
</Carousel>
kennetpostigo commented 8 years ago

@charlesbodman Thank You!

charlesbodman commented 8 years ago

@kennetpostigo You are welcome :)