This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Carousel
用于展示可滚动项目集合的 Jetpack Compose Carousel 组件。
Expo UI 提供三个与官方 Jetpack Compose Carousel API 对应的轮播组件:HorizontalCenteredHeroCarousel、HorizontalMultiBrowseCarousel 和 HorizontalUncontainedCarousel。
注意: Carousel 是一个水平滚动组件,因此父级
Host必须在滚动轴上提供有限宽度。请将matchContents={{ vertical: true }}与style={{ width: '100%' }}(或任意有限宽度)一起使用。详情请参阅 Host 参考中的匹配内容。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
HorizontalCenteredHeroCarousel
在两个较小的预览项之间居中显示一个较大的主展示项,适合突出展示电影海报等内容。
HorizontalMultiBrowseCarousel
在较大的项目旁显示较小的预览项,让用户浏览后续内容。
HorizontalUncontainedCarousel
每个项目都有固定宽度,并支持自由滚动。
API
import { HorizontalCenteredHeroCarousel, HorizontalMultiBrowseCarousel, HorizontalUncontainedCarousel, } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<ComponentType<HorizontalCenteredHeroCarouselProps>>
A hero carousel that centers one large item between two small peek items,
matching Compose's HorizontalCenteredHeroCarousel.
numberMaximum width of the hero item in dp. When unspecified, the hero item will be as wide as possible.
number • Default: CarouselDefaults.MaxSmallItemSizeMaximum width of small peek items in dp.
number • Default: CarouselDefaults.MinSmallItemSizeMinimum width of small peek items in dp.
Type: React.Element<ComponentType<HorizontalMultiBrowseCarouselProps>>
A carousel that shows a large item alongside smaller peek items,
matching Compose's HorizontalMultiBrowseCarousel.
Type: React.Element<ComponentType<HorizontalUncontainedCarouselProps>>
A carousel where each item has a fixed width with free-form scrolling,
matching Compose's HorizontalUncontainedCarousel.
Types
Literal type: string
Fling behavior type for controlling carousel snapping.
Acceptable values are: 'singleAdvance' | 'noSnap'