2016-06-19 11:19:36 +08:00
---
category: Components
2016-11-09 14:43:32 +08:00
type: Data Display
2016-06-19 11:19:36 +08:00
title: Carousel
---
A carousel component. Scales with its container.
2016-09-10 13:43:30 +08:00
## When To Use
2016-06-19 11:19:36 +08:00
- When there is a group of content on the same level.
2017-09-16 11:27:46 +08:00
- When there is insufficient content space, it can be used to save space in the form of a revolving door.
2016-11-29 17:13:24 +08:00
- Commonly used for a group of pictures/cards.
2016-06-19 11:19:36 +08:00
## API
2019-05-06 12:04:39 +08:00
| Property | Description | Type | Default | Version |
2019-05-07 14:57:32 +08:00
| --- | --- | --- | --- | --- |
| afterChange | Callback function called after the current index changes | function(current) | - | |
| autoplay | Whether to scroll automatically | boolean | `false` | |
| beforeChange | Callback function called before the current index changes | function(from, to) | - | |
2019-11-20 20:31:43 +08:00
| dotPosition | The position of the dots, which can be one of `top` `bottom` `left` `right` | string | bottom | |
2020-03-09 17:18:32 +08:00
| dots | Whether to show the dots at the bottom of the gallery, `object` for `dotsClass` and any others | boolean \| { className?:string } | `true` | |
2019-05-07 14:57:32 +08:00
| easing | Transition interpolation function name | string | `linear` | |
| effect | Transition effect | `scrollx` \| `fade` | `scrollx` | |
2016-06-19 11:19:36 +08:00
2017-10-10 13:41:04 +08:00
## Methods
2019-11-20 20:31:43 +08:00
| Name | Description |
| --- | --- |
| goTo(slideNumber, dontAnimate) | Go to slide index, if dontAnimate=true, it happens without animation |
| next() | Change current slide to next slide |
| prev() | Change current slide to previous slide |
2017-10-10 13:41:04 +08:00
2020-04-19 00:51:56 +08:00
Find more APIs in react-slick [documentation ](https://react-slick.neostack.com/docs/api ).