Back to Ant Design

Carousel

components/carousel/index.en-US.md

6.4.43.1 KB
Original Source

When To Use

  • When there is a group of content on the same level.
  • When there is insufficient content space, it can be used to save space in the form of a revolving door.
  • Commonly used for a group of pictures/cards.

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/placement.tsx">Position</code> <code src="./demo/autoplay.tsx">Scroll automatically</code> <code src="./demo/fade.tsx">Fade in</code> <code src="./demo/arrows.tsx" version="5.17.0">Arrows for switching</code> <code src="./demo/dot-duration.tsx" version="5.24.0">Progress of dots</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

PropertyDescriptionTypeDefaultVersionGlobal Config
arrowsWhether to show switch arrowsbooleanfalse5.17.0×
autoplayWhether to scroll automatically, you can specify autoplay={{ dotDuration: true }} to display the progress barboolean | { dotDuration?: boolean }falsedotDuration: 5.24.0×
autoplaySpeedDelay between each auto scroll (in milliseconds)number3000×
adaptiveHeightAdjust the slide's height automaticallybooleanfalse×
dotPlacementThe position of the dots, which can be one of top bottom start endstringbottom×
dotPositionThe position of the dots, which can be one of top bottom left right start end, Please use dotPlacement insteadstringbottom×
dotsWhether to show the dots at the bottom of the gallery, object for dotsClassboolean | { className?: string }true×
draggableEnable scrollable via dragging on desktopbooleanfalse×
fadeWhether to use fade transitionbooleanfalse×
infiniteInfinitely wrap around contentsbooleantrue×
speedAnimation speed in millisecondsnumber500×
easingTransition interpolation function namestringlinear×
effectTransition effectscrollx | fadescrollx×
afterChangeCallback function called after the current index changes(current: number) => void-×
beforeChangeCallback function called before the current index changes(current: number, next: number) => void-×
waitForAnimateWhether to wait for the animation when switchingbooleanfalse×

Find more APIs in react-slick documentation.

Methods

NameDescription
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

Design Token

<ComponentTokenTable component="Carousel"></ComponentTokenTable>

FAQ

How to add custom arrows? {#faq-add-custom-arrows}

See #12479.