Vega Carousel updates
- Fixes to view recycling.
- Removed layout props like
getItemLayoutandlayoutIdbecause the Carousel now determines the layout automatically. - Expanded the list of props to allow for greater customization of the Carousel.
- Added a new callback prop to notify you whenever the current selected item on the Carousel changes.
- The library is now app bundled rather than system bundled (see the following section for more details).
App bundled
This version of Carousel is app bundled, which requires annpm update before releases to make sure you have the latest version. App bundling gives you more control of when you bring in new Carousel changes to your app.
Property grouping
TheitemStyle and animationDuration props can now be grouped with other props.
Example:
Import Vega Carousel
Examples
Horizontal Carousel
This example demonstrates a basic horizontal carousel implementation with focus states and image rendering. The component uses thedataAdapter pattern to manage item retrieval and includes scale animations for a pressed and selected item.
Vertical Carousel
This example shows how to configure a vertical scrolling carousel with custom selection borders. The implementation includes red border styling with yellow stroke effects and uses the anchored selection strategy to keep items locked during navigation.Heterogeneous Carousel
This example showcases the Carousel’s ability to render different item types within a single row by alternating between two distinct layouts based on index. Items at even indices use a 200px width layout, while odd indices use a 500px width layout, demonstrating flexible content presentation.Style
This stylesheet example defines styling constants for a carousel component that supports both horizontal and vertical scrolling orientations. There are container styles for the main carousel (full-screen with black background), item containers in two size variations (200px and 500px wide), and orientation-specific layouts with fixed dimensions (420px height for horizontal, 250px width for vertical).Custom types
The following examples show custom types that you can use to define carousel items and props for the scrollable wrapper components.-
ItemType: A custom data type that represents the structure of individual carousel items. Properties: Theurl (string)property is the image URL that is displayed in the carousel item. Theurl (string)property defines the items passed to the carousel, , andScrollableProps. -
ScrollableProps: Props interface for the scrollable carousel wrapper components. Properties: Thedata (ItemType[])property is an array of item objects to be rendered in the carousel. Thedata (ItemType[])property provides type safety for the component props in the Horizontal, Vertical, and Heterogeneous scrollable wrapper components. This ensures the data passed to these components matches the expected structure.
Features
Data adapter
Vega Carousel supports more customization by allowing you to provide adataAdapter containing various callback functions. For more information, see the Carousel item data adapter callback functions section.
Assuming you have an array called data containing the Carousel item information, you can implement the dataAdapter functions as shown in the following example.
Selection Strategy
TheSelectionStrategy prop controls how a list scrolls and repositions its items when you navigate through them using the D-pad.
Anchored
Theanchored style causes the selected item to stay locked on the initial item’s position. When scrolling, the items reposition so that the selected item remains anchored to that position.
Natural
Thenatural style causes the selected item to move in the direction of the Carousel’s orientation until it reaches the start or end of the list.
Pinned
Thepinned style pins the selected item at a specified position during scrolling for larger sets of items. As your user approaches the beginning or end of the list, the scroll behavior transitions smoothly into the natural flow.
The optional prop pinnedSelectedItemOffset allows you to define the pin location for the selected item when the SelectionStrategy is pinned.
The pinnedSelectedItemOffset prop determines where the selected item stays fixed (or ‘pinned’) in the Carousel’s viewport. You can specify this position in two ways:
- As a percentage (0-100%) of the viewport’s size:
- For vertical Carousels: percentage of height
- For horizontal Carousels: percentage of width
- Using preset values:
- start (equals 0%)
- center (equals 50%)
- end (equals 100%)
Variable scroll speed
The Carousel component introduces a novel feature for controlling scroll speed through severalAnimationDurationProps. Unlike existing components, such as Flatlist or Flashlist, this feature offers enhanced flexibility, so you can fine-tune the scrolling experience.
The itemPressedDuration prop controls the animation duration when pressing on a Carousel item. The itemScrollDuration prop controls the animation duration used to scroll to each Carousel item. The containerSelectionChangeDuration prop controls the animation duration when changing the selected Carousel container.
Selection border
The Carousel component supports displaying a border around a UI item when selected. You can style the border and choose how to draw the content and border for the selected item. You can enable the border by defining theselectionBorder prop. The default props for the selection border are shown in the following example.
borderStrategy prop. The prop supports two types of strategies:
outset- where the border is drawn outside of the original bounds of the item, so the item’s content size remains the same but the overall item size gets bigger.inset- where the border is drawn within the bounds of the item over the item’s content, so while the item’s content size remains the same, part of the item’s content is cropped by the border. The overall item size remains the same.
Props
Selection border props
Animation duration props
Carousel item style props
Carousel item data adapter callback functions
Carousel methods
The Carousel component provides methods for programmatic control of the navigation experience. The following methods are accessible by passing an instance of the current component to theref prop.
Troubleshooting
Vertical scroll only works with a set height
In the case of vertical scrolling (specifically natural scrolling), you need to setcontainerStyle with a fixed height value.

