androidx.wear.compose.material

Interfaces

ButtonBorder

Represents the border stroke used in a Button in different states.

ButtonColors

Represents the background and content colors used in a button in different states.

CheckboxColors

Represents the content colors used in Checkbox in different states.

ChipBorder

Represents the border stroke used in a Chip in different states.

ChipColors

Represents the background and content colors used in a chip in different states.

InlineSliderColors

Represents the background and content colors used in InlineSlider in different states.

PageIndicatorState

An interface for connection between Pager and HorizontalPageIndicator.

PickerScope

Receiver scope which is used by Picker.

PositionIndicatorState

An object representing the relative position of a scrollbar or rolling side button or rotating bezel position.

RadioButtonColors

Represents the content colors used in RadioButton in different states.

ScalingLazyListItemInfo

This interface is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

ScalingLazyListItemScope

This interface is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

ScalingLazyListLayoutInfo

This interface is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

ScalingLazyListScope

This interface is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

ScalingParams

This interface is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

SelectableChipColors

Represents the background and content colors used in SelectableChips in different states.

SplitSelectableChipColors

Represents the background and content colors used in SplitSelectableChips in different states.

SplitToggleChipColors

Represents the background and content colors used in SplitToggleChips in different states.

SwitchColors

Represents the content colors used in Switch in different states.

ThresholdConfig

Interface to compute a threshold between two anchors/states in a swipeable.

TimeSource

An interface which is responsible for retrieving a formatted time.

ToggleButtonColors

Represents the background and content colors used in a toggle button in different states.

ToggleChipColors

Represents the background and content colors used in ToggleChips in different states.

TouchExplorationStateProvider

A functional interface for providing the state of touch exploration services.

Classes

AutoCenteringParams

This class is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

Colors
FixedThreshold

A fixed threshold will be at an offset away from the first anchor.

FractionalThreshold

A fractional threshold will be at a fraction of the way between the two anchors.

PageIndicatorStyle

The style of HorizontalPageIndicator.

PickerGroupItem

A class for representing Picker which will be composed inside a PickerGroup.

PickerGroupState

A state object that can be used to observe the selected Picker.

PickerState

A state object that can be hoisted to observe item selection.

PlaceholderState

A state object that can be used to control placeholders.

PositionIndicatorAlignment

Specifies where in the screen the Position indicator will be.

PositionIndicatorVisibility

Enum used by adapters to specify if the Position Indicator needs to be shown, hidden, or hidden after a small delay.

ResistanceConfig

Specifies how resistance is calculated in swipeable.

RevealActionType

Different values which can trigger the state change from one RevealValue to another.

RevealDirection

Different values SwipeToReveal composable can reveal the actions from.

RevealState

A class to keep track of the state of the composable.

RevealValue

Different values that determine the state of the SwipeToReveal composable, reflected in RevealState.currentValue.

ScalingLazyListAnchorType

This class is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

ScalingLazyListState

This class is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

Shapes

Components are grouped into shape categories based on common features.

SwipeProgress

Collects information about the ongoing swipe or animation in swipeable.

SwipeToDismissBoxState

This class is deprecated. SwipeToDismissBoxState has been migrated, please import it from androidx.wear.compose.foundation.

SwipeToRevealActionColors

A class representing the colors applied in SwipeToReveal actions.

SwipeableState

State of the swipeable modifier.

Typography

Class holding typography definitions as defined by the Wear Material typography specification.

VignettePosition

Possible combinations for vignette state.

Objects

ButtonDefaults

Contains the default values used by Button.

CardDefaults

Contains the default values used by Card

CheckboxDefaults

Contains the default values used by Checkbox.

ChipDefaults

Contains the default values used by Chip

ContentAlpha

Default alpha levels used by Material components.

InlineSliderDefaults

Defaults used by slider

MaterialTheme
PageIndicatorDefaults

Contains the default values used by HorizontalPageIndicator

PickerDefaults

Contains the default values used by Picker

PlaceholderDefaults

Contains the default values used for providing placeholders.

PositionIndicatorDefaults

Contains the default values used for PositionIndicator.

ProgressIndicatorDefaults

Contains the default values used for CircularProgressIndicator.

RadioButtonDefaults

Contains the default values used by RadioButton.

ScalingLazyColumnDefaults

This object is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

SelectableChipDefaults

Contains the default values used by SelectableChips and SplitSelectableChips

StepperDefaults

Defaults used by stepper

SwipeToDismissBoxDefaults

This object is deprecated. Please import SwipeToDismissBoxDefaults from androidx.wear.compose.foundation.

SwipeToRevealDefaults

Defaults for Material SwipeToReveal.

SwipeableDefaults

Contains useful defaults for swipeable and SwipeableState.

SwitchDefaults

Contains the default values used by Switch.

TimeTextDefaults

Contains the default values used by TimeText

ToggleButtonDefaults

Contains the default values used by ToggleButton.

ToggleChipDefaults

Contains the default values used by ToggleChips and SplitToggleChips

Annotations

ExperimentalWearMaterialApi
ScalingLazyScopeMarker

This annotation is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

Enums

SwipeToDismissKeys

Keys used to persistent state in SwipeToDismissBox.

SwipeToDismissValue

This enum is deprecated. SwipeToDismiss has been migrated to androidx.wear.compose.foundation.

Composables

AppCard

Opinionated Wear Material Card that offers a specific 5 slot layout to show information about an application, e.g. a notification.

Button

Wear Material Button that offers a single slot to take any content (text, icon or image).

Card

Base level Wear Material Card that offers a single slot to take any content.

Checkbox

Checkbox provides an animated checkbox for use as a toggle control in ToggleChip or SplitToggleChip.

Chip

Base level Wear Material Chip that offers a single slot to take any content.

CircularProgressIndicator

Indeterminate Material Design circular progress indicator.

CompactButton

Wear Material CompactButton that offers a single slot to take any content (text, icon or image).

CompactChip

A compact Wear Material Chip that offers two slots and a specific layout for an icon and label.

HorizontalPageIndicator

A horizontal indicator for a Pager, representing the currently active page and total pages drawn using a Shape.

Icon

Icon component that draws bitmap using tint, defaulting to LocalContentColor.

InlineSlider

InlineSlider allows users to make a selection from a range of values.

ListHeader

A slot based composable for creating a list header item.

MaterialTheme

MaterialTheme defines the styling principles from the WearOS Material design specification which extends the Material design specification.

OutlinedButton

Wear Material OutlinedButton that offers a single slot to take any content (text, icon or image).

OutlinedChip

Wear Material OutlinedChip that offers three slots and a specific layout for an icon, label and secondaryLabel.

OutlinedCompactButton

Wear Material OutlinedCompactButton that offers a single slot to take any content (text, icon or image).

OutlinedCompactChip

A compact Outlined Wear Material Chip that offers two slots and a specific layout for an icon and label.

Picker

A scrollable list of items to pick from.

PickerGroup

A group of Pickers to build components where multiple pickers are required to be combined together.

PositionIndicator

Creates an PositionIndicator based on the values in a ScalingLazyListState object that a ScalingLazyColumn uses.

ProvideTextStyle

This function is used to set the current value of LocalTextStyle, merging the given style with the current style values for any missing attributes.

RadioButton

RadioButton provides an animated radio button for use as a toggle control in ToggleChip or SplitToggleChip.

Scaffold

Scaffold implements the basic Wear Material Design visual layout structure.

ScalingLazyColumn

A scrolling scaling/fisheye list component that forms a key part of the Wear Material Design language.

SelectableChip

A SelectableChip is a specialized type of Chip that includes a slot for a bi-state selection control such as a radio button.

SplitSelectableChip

A SplitSelectableChip is a specialized type of Chip that includes a slot for a selection control, such as a radio button.

SplitToggleChip

A SplitToggleChip is a specialized type of Chip that includes a slot for a toggle control, such as a toggle or checkbox.

Stepper

Stepper allows users to make a selection from a range of values.

SwipeToDismissBox

Wear Material SwipeToDismissBox that handles the swipe-to-dismiss gesture.

SwipeToRevealCard

SwipeToReveal Material composable for Cards.

SwipeToRevealChip

SwipeToReveal Material composable for Chips.

SwipeToRevealPrimaryAction

A composable which can be used for setting the primary action of material SwipeToRevealCard and SwipeToRevealChip.

SwipeToRevealSecondaryAction

A composable which can be used for setting the secondary action of material SwipeToRevealCard and SwipeToRevealChip.

SwipeToRevealUndoAction

A composable which can be used for setting the undo action of material SwipeToRevealCard and SwipeToRevealChip.

Switch

Switch provides an animated switch for use as a toggle control in ToggleChip or SplitToggleChip.

Text

High level element that displays text and provides semantics / accessibility information.

TimeText

Layout to show the current time and a label at the top of the screen.

TitleCard

Opinionated Wear Material Card that offers a specific 3 slot layout to show interactive information about an application, e.g. a message.

ToggleButton

Wear Material ToggleButton that offers a single slot to take any content (text, icon or image).

ToggleChip

A ToggleChip is a specialized type of Chip that includes a slot for a bi-state toggle control such as a toggle or checkbox.

Vignette

Vignette is whole screen decoration used to blur the top and bottom of the edges of a wearable screen when scrolling content is displayed.

contentColorFor

The Material color system contains pairs of colors that are typically used for the background and content color inside a component.

placeholder

Draws a placeholder shape over the top of a composable and animates a wipe off effect to remove the placeholder.

placeholderShimmer

Modifier to draw a placeholder shimmer over a component.

rememberPickerGroupState

Creates a PickerGroupState that is remembered across compositions.

rememberPickerState

Creates a PickerState that is remembered across compositions.

rememberPlaceholderState

Creates a PlaceholderState that is remembered across compositions.

rememberRevealState

Create and remember a RevealState.

rememberScalingLazyListState

Creates a ScalingLazyListState that is remembered across compositions.

rememberSwipeToDismissBoxState

Create a SwipeToDismissBoxState and remember it.

rememberSwipeableState

Create and remember a SwipeableState with the default animation clock.

Modifiers

edgeSwipeToDismiss

Handles swipe to dismiss from the edge of the viewport.

scrollAway

Scroll an item vertically in/out of view based on a ScrollState.

swipeable

Enable swipe gestures between a set of predefined states.

Top-level functions summary

IndicationNodeFactory
ripple(bounded: Boolean, radius: Dp, color: Color)

Creates a Ripple using the provided values and values inferred from the theme.

IndicationNodeFactory
ripple(color: ColorProducer, bounded: Boolean, radius: Dp)

Creates a Ripple using the provided values and values inferred from the theme.

Extension functions summary

Color
Colors.contentColorFor(backgroundColor: Color)

The Material color system contains pairs of colors that are typically used for the background and content color inside a component.

Unit
CurvedScope.curvedText(
    text: String,
    modifier: CurvedModifier,
    background: Color,
    color: Color,
    fontSize: TextUnit,
    fontFamily: FontFamily?,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    style: CurvedTextStyle?,
    angularDirection: CurvedDirection.Angular?,
    overflow: TextOverflow
)

CurvedText is a component allowing developers to easily write curved text following the curvature a circle (usually at the edge of a circular screen).

inline Unit
<T : Any?> ScalingLazyListScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
)

This function is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

inline Unit
<T : Any?> ScalingLazyListScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
)

This function is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

inline Unit
<T : Any?> ScalingLazyListScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
)

This function is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

inline Unit
<T : Any?> ScalingLazyListScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
)

This function is deprecated. Was moved to androidx.wear.compose.foundation.lazy package.

Top-level properties summary

ProvidableCompositionLocal<Float>

CompositionLocal containing the preferred content alpha for a given position in the hierarchy.

ProvidableCompositionLocal<Color>

CompositionLocal containing the preferred content color for a given position in the hierarchy.

ProvidableCompositionLocal<TextStyle>

CompositionLocal containing the preferred TextStyle that will be used by Text components by default.

Top-level functions

fun ripple(
    bounded: Boolean = true,
    radius: Dp = Dp.Unspecified,
    color: Color = Color.Unspecified
): IndicationNodeFactory

Creates a Ripple using the provided values and values inferred from the theme.

A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.

A Ripple responds to PressInteraction.Press by starting a new animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.

MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.

You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.

To create a Ripple with a manually defined color that can change over time, see the other ripple overload with a ColorProducer parameter. This will avoid unnecessary recompositions when changing the color, and preserve existing ripple state when the color changes.

Parameters
bounded: Boolean = true

If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position.

radius: Dp = Dp.Unspecified

the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size.

color: Color = Color.Unspecified

the color of the ripple. This color is usually the same color used by the text or iconography in the component. This color will then have alpha applied to calculate the final color used to draw the ripple. If Color.Unspecified is provided the color used will be the default ripple color instead.

fun ripple(
    color: ColorProducer,
    bounded: Boolean = true,
    radius: Dp = Dp.Unspecified
): IndicationNodeFactory

Creates a Ripple using the provided values and values inferred from the theme.

A Ripple is a Material implementation of Indication that expresses different Interactions by drawing ripple animations and state layers.

A Ripple responds to PressInteraction.Press by starting a new ripple animation, and responds to other Interactions by showing a fixed state layer with varying alpha values depending on the Interaction.

MaterialTheme provides Ripples using androidx.compose.foundation.LocalIndication, so a Ripple will be used as the default Indication inside components such as androidx.compose.foundation.clickable and androidx.compose.foundation.indication, in addition to Material provided components that use a Ripple as well.

You can also explicitly create a Ripple and provide it to custom components in order to change the parameters from the default, such as to create an unbounded ripple with a fixed size.

To create a Ripple with a static color, see the ripple overload with a Color parameter. This overload is optimized for Ripples that have dynamic colors that change over time, to reduce unnecessary recompositions.

Parameters
color: ColorProducer

the color of the ripple. This color is usually the same color used by the text or iconography in the component. This color will then have alpha applied to calculate the final * color used to draw the ripple. If you are creating this ColorProducer outside of composition (where it will be automatically remembered), make sure that its instance is stable (such as by remembering the object that holds it), or remember the returned ripple object to make sure that ripple nodes are not being created each recomposition.

bounded: Boolean = true

If true, ripples are clipped by the bounds of the target layout. Unbounded ripples always animate from the target layout center, bounded ripples animate from the touch position.

radius: Dp = Dp.Unspecified

the radius for the ripple. If Dp.Unspecified is provided then the size will be calculated based on the target layout size.

Extension functions

Colors.contentColorFor

fun Colors.contentColorFor(backgroundColor: Color): Color

The Material color system contains pairs of colors that are typically used for the background and content color inside a component. For example, a Button typically uses primary for its background, and onPrimary for the color of its content (usually text or iconography).

This function tries to match the provided backgroundColor to a 'background' color in this Colors, and then will return the corresponding color used for content. For example, when backgroundColor is Colors.primary, this will return Colors.onPrimary.

If backgroundColor does not match a background color in the theme, this will return Color.Unspecified.

Returns
Color

the matching content color for backgroundColor. If backgroundColor is not present in the theme's Colors, then returns Color.Unspecified.

See also
contentColorFor

CurvedScope.curvedText

fun CurvedScope.curvedText(
    text: String,
    modifier: CurvedModifier = CurvedModifier,
    background: Color = Color.Unspecified,
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontFamily: FontFamily? = null,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    style: CurvedTextStyle? = null,
    angularDirection: CurvedDirection.Angular? = null,
    overflow: TextOverflow = TextOverflow.Clip
): Unit

CurvedText is a component allowing developers to easily write curved text following the curvature a circle (usually at the edge of a circular screen). CurvedText can be only created within the CurvedLayout to ensure the best experience, like being able to specify to positioning.

The default style uses the LocalTextStyle provided by the MaterialTheme / components, converting it to a CurvedTextStyle. Note that not all parameters are used by curvedText.

If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override, then convert to CurvedTextStyle

For ease of use, commonly used parameters from CurvedTextStyle are also present here. The order of precedence is as follows:

  • If a parameter is explicitly set here (i.e, it is not null or TextUnit.Unspecified), then this parameter will always be used.

  • If a parameter is not set, (null or TextUnit.Unspecified), then the corresponding value from style will be used instead.

Additionally, for color, if color is not set, and style does not have a color, then LocalContentColor will be used with an alpha of LocalContentAlpha- this allows this curvedText or element containing this curvedText to adapt to different background colors and still maintain contrast and accessibility.

For samples explicitly specifying style see:

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.wear.compose.foundation.CurvedAlignment
import androidx.wear.compose.foundation.CurvedLayout
import androidx.wear.compose.foundation.CurvedModifier
import androidx.wear.compose.foundation.curvedColumn
import androidx.wear.compose.foundation.curvedRow
import androidx.wear.compose.foundation.padding
import androidx.wear.compose.material.curvedText

CurvedLayout() {
    curvedColumn(angularAlignment = CurvedAlignment.Angular.Center) {
        curvedRow {
            curvedText("Red", color = Color.Red)
            curvedText(
                "White On Green",
                color = Color.White,
                background = Color.Green,
                modifier = CurvedModifier.padding(angular = 5.dp),
            )
            curvedText("Big", fontSize = 24.sp)
            curvedText(
                "Extra Bold",
                fontWeight = FontWeight.ExtraBold,
                modifier = CurvedModifier.padding(angular = 5.dp),
            )
        }
        curvedRow {
            curvedText("Default")
            curvedText(
                "Italic",
                fontStyle = FontStyle.Italic,
                modifier = CurvedModifier.padding(angular = 5.dp),
            )
            curvedText("Monospaced", fontFamily = FontFamily.Monospace)
        }
    }
}

For examples using CompositionLocal to specify the style, see:

import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.wear.compose.foundation.CurvedLayout
import androidx.wear.compose.foundation.CurvedTextStyle
import androidx.wear.compose.material.LocalContentAlpha
import androidx.wear.compose.material.LocalContentColor
import androidx.wear.compose.material.LocalTextStyle
import androidx.wear.compose.material.ProvideTextStyle
import androidx.wear.compose.material.curvedText

CompositionLocalProvider(
    LocalContentColor provides Color.Cyan,
    LocalContentAlpha provides 0.5f,
    LocalTextStyle provides TextStyle(fontFamily = FontFamily.Serif),
) {
    val greenStyle = LocalTextStyle.current.copy(color = Color.Green)
    CurvedLayout {
        curvedText("Serif Cyan 50%")
        curvedText("Green", style = CurvedTextStyle(greenStyle))
    }
}

ProvideTextStyle(
    value =
        TextStyle(color = Color.Green, background = Color.White, fontWeight = FontWeight.Bold)
) {
    CurvedLayout(anchor = 90f) { curvedText("Green On White") }
}

For more information, see the Curved Text guide.

Parameters
text: String

The text to display

modifier: CurvedModifier = CurvedModifier

The CurvedModifier to apply to this curved text.

background: Color = Color.Unspecified

The background color for the text.

color: Color = Color.Unspecified

Color to apply to the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor.

fontSize: TextUnit = TextUnit.Unspecified

The size of glyphs to use when painting the text. See TextStyle.fontSize.

fontFamily: FontFamily? = null

The font family to be used when rendering the text.

fontWeight: FontWeight? = null

The thickness of the glyphs, in a range of 1, 1000. see FontWeight

fontStyle: FontStyle? = null

The typeface variant to use when drawing the letters (e.g. italic).

fontSynthesis: FontSynthesis? = null

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

style: CurvedTextStyle? = null

Specifies the style to use.

angularDirection: CurvedDirection.Angular? = null

Specify if the text is laid out clockwise or anti-clockwise, and if those needs to be reversed in a Rtl layout. If not specified, it will be inherited from the enclosing curvedRow or CurvedLayout See CurvedDirection.Angular.

overflow: TextOverflow = TextOverflow.Clip

How visual overflow should be handled. Note that this takes into account only explicit size curved modifiers in this element, to size this element matching the parent's, add a CurvedModifier.weight here.

ScalingLazyListScope.items

inline fun <T : Any?> ScalingLazyListScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
): Unit

Adds an array of items.

Parameters
items: Array<T>

the data array

noinline key: ((item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. 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.

crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit

the content displayed by a single item

ScalingLazyListScope.items

inline fun <T : Any?> ScalingLazyListScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

noinline key: ((item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. 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.

crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit

the content displayed by a single item

ScalingLazyListScope.itemsIndexed

inline fun <T : Any?> ScalingLazyListScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
): Unit

Adds an array of items where the content of an item is aware of its index.

Parameters
items: Array<T>

the data array

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. 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.

crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit

the content displayed by a single item

ScalingLazyListScope.itemsIndexed

inline fun <T : Any?> ScalingLazyListScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
): Unit

Adds a list of items where the content of an item is aware of its index.

Parameters
items: List<T>

the data list

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. 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.

crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit

the content displayed by a single item

Top-level properties

LocalContentAlpha

val LocalContentAlphaProvidableCompositionLocal<Float>

CompositionLocal containing the preferred content alpha for a given position in the hierarchy. This alpha is used for text and iconography (Text and Icon) to emphasize / de-emphasize different parts of a component. See the Material guide on Text Legibility for more information on alpha levels used by text and iconography.

See ContentAlpha for the default levels used by most Material components.

MaterialTheme sets this to ContentAlpha.high by default, as this is the default alpha for body text.

LocalContentColor

val LocalContentColorProvidableCompositionLocal<Color>

CompositionLocal containing the preferred content color for a given position in the hierarchy. This typically represents the on color for a color in Colors. For example, if the background color is Colors.surface, this color is typically set to Colors.onSurface.

This color should be used for any typography / iconography, to ensure that the color of these adjusts when the background color changes. For example, on a dark background, text should be light, and on a light background, text should be dark.

Defaults to Color.White if no color has been explicitly set.

LocalTextStyle

val LocalTextStyleProvidableCompositionLocal<TextStyle>

CompositionLocal containing the preferred TextStyle that will be used by Text components by default. To set the value for this CompositionLocal, see ProvideTextStyle which will merge any missing TextStyle properties with the existing TextStyle set in this CompositionLocal.

See also
ProvideTextStyle