ListHeader

Functions summary

Unit
@Composable
ListHeader(
    modifier: Modifier,
    backgroundColor: Color,
    contentColor: Color,
    content: @Composable RowScope.() -> Unit
)

A slot based composable for creating a list header item.

Functions

@Composable
fun ListHeader(
    modifier: Modifier = Modifier,
    backgroundColor: Color = Color.Transparent,
    contentColor: Color = MaterialTheme.colors.onSurfaceVariant,
    content: @Composable RowScope.() -> Unit
): Unit

A slot based composable for creating a list header item. List header items are typically expected to be text. The contents provided will have text and colors effects applied based on the MaterialTheme. The contents will be start and end padded and should cover up to 3 lines of text.

Example usage:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text

ScalingLazyColumn(modifier = Modifier.fillMaxWidth()) {
    item { ListHeader { Text("Header1") } }
    items(5) {
        Chip(
            onClick = {},
            label = { Text("List item $it") },
            colors = ChipDefaults.secondaryChipColors(),
        )
    }
    item { ListHeader { Text("Header2") } }
    items(5) {
        Chip(
            onClick = {},
            label = { Text("List item ${it + 5}") },
            colors = ChipDefaults.secondaryChipColors(),
        )
    }
}
Parameters
modifier: Modifier = Modifier

The modifier for the list header

backgroundColor: Color = Color.Transparent

The background color to apply - typically Color.Transparent

contentColor: Color = MaterialTheme.colors.onSurfaceVariant

The color to apply to content

content: @Composable RowScope.() -> Unit

Slot for displayed header text