VerticalPager

Composable Function

Android
@Composable
public fun VerticalPager(
    state: PagerState,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    beyondViewportPageCount: Int = PagerDefaults.BeyondViewportPageCount,
    flingBehavior: TargetedFlingBehavior = PagerDefaults.snapFlingBehavior(state = state),
    userScrollEnabled: Boolean = true,
    reverseLayout: Boolean = false,
    key: ((index: Int) -> Any)? = null,
    rotaryScrollableBehavior: RotaryScrollableBehavior? =
        RotaryScrollableDefaults.snapBehavior(state),
    content: @Composable PagerScope.(page: Int) -> Unit,
)

A vertically scrolling Pager optimized for Wear OS devices. This component wraps the standard Compose Foundation VerticalPager and provides Wear-specific enhancements to improve performance, usability, and adherence to Wear OS design guidelines.

VerticalPager supports rotary input by default. Rotary input allows users to scroll through the pager's content - by using a crown or a rotating bezel on their Wear OS device. It can be modified or turned off using the rotaryScrollableBehavior parameter.

Please refer to the sample to learn how to use this API.

Parameters

stateThe state to control this pager
modifierA modifier instance to be apply to this Pager outer layout
contentPaddinga padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. You can use it to add a padding before the first page or after the last one.
beyondViewportPageCountPages to compose and layout before and after the list of visible pages. Note: Be aware that using a large value for beyondViewportPageCount will cause a lot of pages to be composed, measured and placed which will defeat the purpose of using lazy loading. This should be used as an optimization to pre-load a couple of pages before and after the visible ones. This does not include the pages automatically composed and laid out by the pre-fetcher in the direction of the scroll during scroll events.
flingBehaviorThe TargetedFlingBehavior to be used for post scroll gestures.
userScrollEnabledwhether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using PagerState.scroll even when it is disabled.
reverseLayoutreverse the direction of scrolling and layout.
keya stable and unique key representing the item. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. If null is passed the position in the list will represent the key.
rotaryScrollableBehaviorParameter for changing rotary behavior. We recommend to use RotaryScrollableDefaults.snapBehavior with pagerState parameter. Passing null turns off the rotary handling if it is not required.
contentA composable function that defines the content of each page displayed by the Pager. This is where the UI elements that should appear within each page should be placed.