Overview
Carousel is a production-ready carousel component included in the sunpeak Starter Kit. It provides smooth horizontal scrolling with navigation arrows, edge gradients, and persistent state tracking. Built on embla-carousel-react with wheel gesture support.
Import
Basic Usage
Props
children
- Type:
React.ReactNode - Optional: Yes
- Description: The carousel items to display. Typically
Cardcomponents, but can be any React nodes.
gap
- Type:
number - Optional: Yes
- Default:
16 - Description: Gap between carousel items in pixels.
showArrows
- Type:
boolean - Optional: Yes
- Default:
true - Description: Whether to show navigation arrows (Previous/Next buttons). Arrows only appear when there are more items to scroll.
showEdgeGradients
- Type:
boolean - Optional: Yes
- Default:
true - Description: Whether to show gradient overlays at the left/right edges to indicate more content. Gradients appear when scrolling is possible in that direction.
cardWidth
- Type:
number | { inline?: number; fullscreen?: number } - Optional: Yes
- Default:
220 - Description: Width of each carousel item in pixels. Can be:
- A single number for consistent width
- An object with
inlineand/orfullscreenproperties to set different widths based on display mode
className
- Type:
string - Optional: Yes
- Description: Additional CSS classes to apply to the carousel container.
State Management
The carousel usesuseWidgetState to persist the current scroll position across sessions: