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
|
2020-05-31 11:48:34 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/antfincdn/%24C9tmj978R/Carousel.svg
|
2016-06-19 11:19:36 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
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
|
|
|
| --- | --- | --- | --- | --- |
|
2020-06-17 23:18:14 +08:00
|
|
|
| autoplay | Whether to scroll automatically | boolean | false | |
|
2020-07-01 22:15:26 +08:00
|
|
|
| dotPosition | The position of the dots, which can be one of `top` `bottom` `left` `right` | string | `bottom` | |
|
|
|
|
| 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` | |
|
2020-10-21 10:33:43 +08:00
|
|
|
| afterChange | Callback function called after the current index changes | function(current) | - | |
|
|
|
|
| beforeChange | Callback function called before the current index changes | function(from, to) | - | |
|
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).
|
2021-05-06 14:37:39 +08:00
|
|
|
|
|
|
|
## FAQ
|
|
|
|
|
|
|
|
### How to add custom arrows?
|
|
|
|
|
|
|
|
See [#12479](https://github.com/ant-design/ant-design/issues/12479).
|