Build apps faster with our new App builder! Check it out →

ListSubHeader

Android

Component in Wear Material 3 Compose

A two slot based composable for creating a list sub-header item. [ListSubHeader]s offer slots for an icon and for a text label. The contents will be start and end padded.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material3:1.0.0-alpha27")
}

Overloads

@Composable
fun ListSubHeader(
    modifier: Modifier = Modifier,
    backgroundColor: Color = Color.Transparent,
    contentColor: Color = ListHeaderDefaults.subHeaderContentColor,
    contentPadding: PaddingValues = ListHeaderDefaults.SubHeaderContentPadding,
    icon: (@Composable BoxScope.() -> Unit)? = null,
    label: @Composable RowScope.() -> Unit,
)

Parameters

namedescription
modifierThe modifier for the [ListSubHeader].
backgroundColorThe background color to apply - typically Color.Transparent
contentColorThe color to apply to content.
contentPaddingThe spacing values to apply internally between the container and the content.
iconA slot for providing icon to the [ListSubHeader].
labelA slot for providing label to the [ListSubHeader].

Code Examples

ListSubHeaderSample

@Composable
fun ListSubHeaderSample() {
    ListSubHeader { Text("SubHeader") }
}

ListSubHeaderWithIconSample

@Composable
fun ListSubHeaderWithIconSample() {
    ListSubHeader(
        label = { Text(text = "SubHeader") },
        icon = { Icon(imageVector = Icons.Outlined.Home, "home") }
    )
}
by @alexstyl