Carousal
A carousel component for displaying multiple items in a sliding interface.
Installation
npm install @cleartrip/ct-design-carousal
# or
pnpm add @cleartrip/ct-design-carousal
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Carousal } from '@cleartrip/ct-design-carousal';
function Example() {
return (
<Carousal>
{/* Basic usage */}
</Carousal>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | `ReactNode[] | JSX.Element[]` | — | ✅ Yes |
onSlide | (index: number) => void | — | No | : callback function to handle the stuffs on slide. |
showSliderIcons | boolean | : false | No | : to display the right and left chevron incase of desktop carousal |
autoSwipeDuration | number | — | No | : to set the autoSwipe duration in ms. |
showDots | boolean | : true | No | : to manage the dots to be shown over the carousal. |
startIndex | number | : 0 | No | : to pass the startIndex to the carousal |
maxDotsToShow | number | : 10 | No | : to ensure the number of dots not to overflow and limiting to a |
CustomDotsComponent | ICustomDotsComponent | — | No | : enabling a custom dots with chevorn too like we have in desktop carousal. |
autoPlay | boolean | — | No | For providing the autoplay boolena flag. |
autoPlaySpeed | number | — | No | autoplay speed in milliseconds |
dotsStripPosition | string | — | No | : this props defined the dots position like INSIDE or OUSIDE |
customSliderIconWithDots | boolean | — | No | to ensure slider icon with dots |
CustomLeftCarousalComponent | ICustomCarousalComponent | — | No | custom left chevron |
CustomRightCarousalComponent | ICustomCarousalComponent | — | No | custom right chevron |
wrapperHeight | string | — | No | : this props defined the height of the wrapper |
slideTranslatePercentage | number | — | No | styled configs to modify css at each level |
IDotsStripPosition
INSIDE— INSIDEOUTSIDE— OUTSIDE
ON_HOVER_TYPE
ENTER— ENTERLEAVE— LEAVE
SLIDER_DIRECTION
NEXT— LEFTPREV— RIGHT
ACTION
STOP_SLIDING— STOP_SLIDINGSTART_SWIPING— START_SWIPING
STRIP_POSITION
INSIDE— INSIDEOUTSIDE— OUTSIDE
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Carousal } from 'yagami/core/components';
+ import { Carousal } from '@cleartrip/ct-design-carousal';