VerticalList

Functions summary

Unit
@Composable
VerticalList(
    modifier: Modifier,
    state: ListState,
    contentPadding: PaddingValues,
    userScrollEnabled: Boolean,
    overscrollEffect: OverscrollEffect?,
    flingBehavior: FlingBehavior,
    reverseLayout: Boolean,
    horizontalAlignment: Alignment.Horizontal,
    verticalArrangement: Arrangement.Vertical,
    content: ListScope.() -> Unit
)

This is a scrolling list component that only composes and lays out the currently visible items.

Unit
@Composable
VerticalList(
    title: @Composable () -> Unit,
    modifier: Modifier,
    state: ListState,
    contentPadding: PaddingValues,
    userScrollEnabled: Boolean,
    overscrollEffect: OverscrollEffect?,
    flingBehavior: FlingBehavior,
    reverseLayout: Boolean,
    horizontalAlignment: Alignment.Horizontal,
    verticalArrangement: Arrangement.Vertical,
    content: ListScope.() -> Unit
)

This is a scrolling list component that only composes and lays out the currently visible items.

Functions

VerticalList

@Composable
fun VerticalList(
    modifier: Modifier = Modifier,
    state: ListState = rememberListState(),
    contentPadding: PaddingValues = VerticalListDefaults.contentPadding,
    userScrollEnabled: Boolean = true,
    overscrollEffect: OverscrollEffect? = rememberOverscrollEffect(),
    flingBehavior: FlingBehavior = VerticalListDefaults.flingBehavior(state),
    reverseLayout: Boolean = false,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    verticalArrangement: Arrangement.Vertical = VerticalListDefaults.verticalArrangement,
    content: ListScope.() -> Unit
): Unit

This is a scrolling list component that only composes and lays out the currently visible items. It is based on androidx.compose.foundation.lazy.LazyColumn, but with extra functionality and customized behavior required for Jetpack Compose Glimmer. For Jetpack Compose Glimmer applications, it is recommended to use VerticalList instead of androidx.compose.foundation.lazy.LazyColumn, as it is specifically designed to provide seamless focus-based navigation, visual scrim edge effects and support for focus-aware snap behavior.

The content block defines a DSL which allows you to emit items of different types. For example, you can use ListScope.item to add a single item and ListScope.items to add a list of items.

See the other VerticalList overload for a variant with a title slot.

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text
import androidx.xr.glimmer.list.VerticalList
import androidx.xr.glimmer.list.items

VerticalList {
    item { ListItem { Text("Header") } }
    items(count = 10) { index -> ListItem { Text("Item-$index") } }
    item { ListItem { Text("Footer") } }
}
Parameters
modifier: Modifier = Modifier

the modifier to apply to this layout.

state: ListState = rememberListState()

the state object to be used to control or observe the list's state.

contentPadding: PaddingValues = VerticalListDefaults.contentPadding

a 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 item or after the last one.

userScrollEnabled: Boolean = true

If user gestures are enabled.

overscrollEffect: OverscrollEffect? = rememberOverscrollEffect()

the OverscrollEffect that will be used to render overscroll for this layout. Note that the OverscrollEffect.node will be applied internally as well - you do not need to use Modifier.overscroll separately.

flingBehavior: FlingBehavior = VerticalListDefaults.flingBehavior(state)

logic describing fling and snapping behavior when drag has finished.

reverseLayout: Boolean = false

reverses the direction of scrolling and layout.

horizontalAlignment: Alignment.Horizontal = Alignment.Start

aligns items horizontally.

verticalArrangement: Arrangement.Vertical = VerticalListDefaults.verticalArrangement

is arrangement for items. This only applies if the content is smaller than the viewport.

content: ListScope.() -> Unit

a block which describes the content. Inside this block you can use methods like ListScope.item to add a single item or ListScope.items to add a list of items.

VerticalList

@Composable
fun VerticalList(
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    state: ListState = rememberListState(),
    contentPadding: PaddingValues = VerticalListDefaults.contentPaddingWithTitle,
    userScrollEnabled: Boolean = true,
    overscrollEffect: OverscrollEffect? = rememberOverscrollEffect(),
    flingBehavior: FlingBehavior = VerticalListDefaults.flingBehavior(state),
    reverseLayout: Boolean = false,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    verticalArrangement: Arrangement.Vertical = VerticalListDefaults.verticalArrangement,
    content: ListScope.() -> Unit
): Unit

This is a scrolling list component that only composes and lays out the currently visible items. It is based on androidx.compose.foundation.lazy.LazyColumn, but with extra functionality and customized behavior required for Jetpack Compose Glimmer. Jetpack Compose Glimmer applications should always use VerticalList instead of LazyColumn to ensure correct behavior.

The content block defines a DSL which allows you to emit items of different types. For example, you can use ListScope.item to add a single item and ListScope.items to add a list of items.

This overload of VerticalList contains a title slot. The title is expected to be a androidx.xr.glimmer.TitleChip. It is positioned at the top center and visually overlaps the list content. The list is vertically offset to start from the title's vertical center. When the list is scrolled, the title remains static.

See the other VerticalList overload for a variant with no title slot.

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text
import androidx.xr.glimmer.TitleChip
import androidx.xr.glimmer.list.VerticalList
import androidx.xr.glimmer.list.items

val ingredientItems =
    listOf("Milk", "Flour", "Egg", "Salt", "Apples", "Butter", "Vanilla", "Sugar", "Cinnamon")
VerticalList(title = { TitleChip { Text("Ingredients") } }) {
    items(ingredientItems) { text -> ListItem { Text(text) } }
}
Parameters
title: @Composable () -> Unit

a composable slot for the list title, expected to be a androidx.xr.glimmer.TitleChip. It overlaps the list, positioned at the top-center, and remains stuck to the top when the list is scrolled.

modifier: Modifier = Modifier

applies to the layout that contains both list and title.

state: ListState = rememberListState()

the state object to be used to control or observe the list's state.

contentPadding: PaddingValues = VerticalListDefaults.contentPaddingWithTitle

a 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 item or after the last one. The list is vertically offset to start from the title's vertical center, so custom content paddings must provide sufficient space to avoid content being obscured.

userScrollEnabled: Boolean = true

If user gestures are enabled.

overscrollEffect: OverscrollEffect? = rememberOverscrollEffect()

the OverscrollEffect that will be used to render overscroll for this layout. Note that the OverscrollEffect.node will be applied internally as well - you do not need to use Modifier.overscroll separately.

flingBehavior: FlingBehavior = VerticalListDefaults.flingBehavior(state)

logic describing fling and snapping behavior when drag has finished.

reverseLayout: Boolean = false

reverses the direction of scrolling and layout.

horizontalAlignment: Alignment.Horizontal = Alignment.Start

aligns items horizontally.

verticalArrangement: Arrangement.Vertical = VerticalListDefaults.verticalArrangement

is arrangement for items. This only applies if the content is smaller than the viewport.

content: ListScope.() -> Unit

a block which describes the content. Inside this block you can use methods like ListScope.item to add a single item or ListScope.items to add a list of items.