Carousel

Carousel widget

The Carousel Widget allows you to create and render carousels, enabling the presentation of multiple items in a visually engaging and interactive slideshow format within your application.

Test in Kitchen Sink (opens in a new tab)

Properties

PropertyTypeDescription
childrenarrayList of widgets
onItemChangeactionDispatch when an carousel item is in focus. For SingleView, this happens when the item is scroll into view. For scrolling MultiView, the event dispatches only when you tap on the item. The index of the item can be retrieved using 'selectedIndex'.
item-templateobjectSee properties

Styles

PropertyTypeDescription
layoutstringShow a SingleView (on screen one at a time), MultiView (scrolling items), or automatically switch between the views with autoLayoutBreakpoint
autoLayoutBreakpointintegerShow multiple views on the carousel if the breakpoint is equal or larger than this threshold, otherwise show single view. (default 768)
autoplaybooleanIf true, Enables autoplay, sliding one page at a time. Default (false)
autoplayIntervalintegerSets the duration in seconds for the autoplay. Default (4 second)
heightintegerThe height of each view
gapintegerThe gap between each views, but also act as a left-right margin in a single view
leadingGapintegerThe space before the first item. Note that the left edge of the scroll area is still controlled by padding or margin.
trailingGapintegerThe space after the last item. Note that the right edge of the scroll area is still controlled by padding or margin.
singleItemWidthRationumberThe screen width ratio for each carousel item (in single item mode). Value ranges from 0.0 to 1.0 for the full width. (default 1.0)
multipleItemWidthRationumberThe screen width ratio for each carousel item (in multiple item mode). Value ranges from 0.0 to 1.0 for the full width (default 0.6)
indicatorTypestringHow the view indicator should be displayed
indicatorPositionstringWhere to display the indicator if specified
indicatorWidthintegerSets the width of the carousel indicators within the Carousel
indicatorHeightintegerAdjusts the height of the carousel indicators within the Carousel
indicatorMarginstring or integerThe margin around each indicator
indicatorPaddingstring or integerThe padding around the indicator
aspectRationumberAspect ratio is used if no height have been declared.
autoPlayAnimationDurationintegerThe animation duration between two transitioning pages while in auto playback.
autoPlayCurvestringDetermines the animation curve physics.
enlargeCenterPagebooleanDetermines if current page should be larger than the side images, creating a feeling of depth in the carousel.
enlargeFactornumberHow much the pages next to the center page will be scaled down. If enlargeCenterPage is false, this property has no effect.
directionstringThe axis along which the carousel view scrolls.
cacheKeystringPass a cacheKey if you want to keep the carousel's item position when it was recreated
buildOnDemandbooleanBuild the carousel items only when its visible in the screen. Default - false
buildOnDemandLengthintegerBuild the carousel items when its visible in the screen only when the item is greater or equal to this length. Default - 6

Box Styles (Inherited)

This widget also inherits these styles

PropertyTypeDescription
margininteger/stringMargin with CSS-style notation (1 to 4 integers) e.g. margin: 5 20 5
paddinginteger/stringPadding with CSS-style notation (1 to 4 integers) e.g. padding: 5 20 5
backgroundColorColorThe background color of this widget.
backgroundImageBackgroundImageThe background image of this widget.
backgroundGradientGradientThe background gradient of this widget.
borderBorderThe border of this widget.
shadowShadowThe shadow of this widget
clipContentbooleanSome widgets (such as Image) may bleed through the container when borderRadius is set. Use this to apply a clipping to ensure this does not happen.
widthintegerThe width of this widget.
heightintegerThe height of this widget.
borderRadiusstring or integerThe border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
borderColorinteger or stringSets the border color, starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange.
borderWidthintegerThickness of the border. Minimum value should be 0.
shadowColorinteger or stringSets the box shadow color starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange.
shadowOffsetarrayThe values in the array define the horizontal and vertical offset of the shadow. Example: if the shadowOffset is set to [2, 4], the shadow will be offset by 2 pixels horizontally and 4 pixels vertically from its original position.
shadowRadiusstring or integerThe border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
shadowStylestringThe blur style to apply on the shadow: normal, solid, outer, inner.

Base Styles (Inherited)

This widget also inherits these styles

PropertyTypeDescription
visiblebooleanToggle a widget visibility on/off. Note that an invisible widget will not occupy UI space, unless the visibilityTransitionDuration is specified.
visibilityTransitionDurationnumberSpecify the duration in seconds when a widget animates between visible and not visible state. Note that setting this value will cause the widget to still occupy the UI space even when it is not visible.
elevationintegerThe z-coordinate at which to place this material relative to its parent. A non-zero value will show a shadow, with its size relative to the elevation value. (Minimum: 0, Maximum: 24)
elevationShadowColorColorThe shadow color for the elevation.
elevationBorderRadiusinteger / stringIf the widget has a borderRadius, this should be changed to have the same value. Use with CSS-like notation (1 to 4 integers).
alignmentAlignmentAlign this widget relative to its parent.
stackPositionTopintegerThe distance of the child's top edge from the top of the stack. This is applicable only for Stack's children.
stackPositionBottomintegerThe distance that the child's bottom edge from the bottom of the stack. This is applicable only for Stack's children.
stackPositionLeftintegerThe distance that the child's left edge from the left of the stack. This is applicable only for Stack's children.
stackPositionRightintegerThe distance that the child's right edge from the right of the stack. This is applicable only for Stack's children.
captureWebPointerbooleanApplicable for Web only. When overlaying widgets on top of certain HTML container (e.g., Maps), the mouse click is captured by the HTML container, causing issue interacting with the widget. Use this to capture and maintain the mouse pointer on your widget.

item-template

PropertyTypeDescription
datastringBind to an array of data from an API response or a variable
namestringSet the name to reference as you iterate through the array of data
templatewidgetThe widget to render for each item