ListItemKt

Added in 1.0.0-alpha01

public final class ListItemKt


Summary

Public methods

static final void
@Composable
ListItem(
    @NonNull Modifier modifier,
    @Composable Function0<Unit> supportingLabel,
    @Composable Function0<Unit> leadingIcon,
    @Composable Function0<Unit> trailingIcon,
    @NonNull Shape shape,
    @NonNull Color color,
    @NonNull Color contentColor,
    BorderStroke border,
    @NonNull PaddingValues contentPadding,
    MutableInteractionSource interactionSource,
    @Composable @NonNull Function0<Unit> content
)

ListItem is a component used to represent a single item in a androidx.xr.glimmer.list.VerticalList.

static final void
@Composable
ListItem(
    @NonNull Function0<Unit> onClick,
    @NonNull Modifier modifier,
    @Composable Function0<Unit> supportingLabel,
    @Composable Function0<Unit> leadingIcon,
    @Composable Function0<Unit> trailingIcon,
    @NonNull Shape shape,
    @NonNull Color color,
    @NonNull Color contentColor,
    BorderStroke border,
    @NonNull PaddingValues contentPadding,
    MutableInteractionSource interactionSource,
    @Composable @NonNull Function0<Unit> content
)

ListItem is a component used to represent a single item in a androidx.xr.glimmer.list.VerticalList.

Public methods

@Composable
public static final void ListItem(
    @NonNull Modifier modifier,
    @Composable Function0<Unit> supportingLabel,
    @Composable Function0<Unit> leadingIcon,
    @Composable Function0<Unit> trailingIcon,
    @NonNull Shape shape,
    @NonNull Color color,
    @NonNull Color contentColor,
    BorderStroke border,
    @NonNull PaddingValues contentPadding,
    MutableInteractionSource interactionSource,
    @Composable @NonNull Function0<Unit> content
)

ListItem is a component used to represent a single item in a androidx.xr.glimmer.list.VerticalList. A ListItem has a primary label content, and may also have any combination of supportingLabel, leadingIcon, and trailingIcon. The supporting label is displayed below the primary label and can be used to provide additional information. A ListItem fills the maximum width available by default.

This ListItem is focusable - see the other ListItem overload for a clickable ListItem.

A simple ListItem with just a primary label:

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem { Text("Primary Label") }

A ListItem with a primary and supporting label:

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem(supportingLabel = { Text("Supporting Label") }) { Text("Primary Label") }

A ListItem with a primary label, a supporting label, and a leading icon:

import androidx.xr.glimmer.Icon
import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem(
    supportingLabel = { Text("Supporting Label") },
    leadingIcon = { Icon(FavoriteIcon, "Localized description") },
) {
    Text("Primary Label")
}
Parameters
@NonNull Modifier modifier

the Modifier to be applied to this list item

@Composable Function0<Unit> supportingLabel

optional supporting label to be placed underneath the primary label content

@Composable Function0<Unit> leadingIcon

optional leading icon to be placed before the primary label content. This is typically an Icon.

@Composable Function0<Unit> trailingIcon

optional trailing icon to be placed after the primary label content. This is typically an Icon.

@NonNull Shape shape

the Shape used to clip this list item, and also used to draw the background and border

@NonNull Color color

background color of this list item

@NonNull Color contentColor

content color used by components inside content, and supportingLabel.

BorderStroke border

the border to draw around this list item

@NonNull PaddingValues contentPadding

the spacing values to apply internally between the container and the content

MutableInteractionSource interactionSource

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this list item. You can use this to change the list item's appearance or preview the list item in different states. Note that if null is provided, interactions will still happen internally.

@Composable @NonNull Function0<Unit> content

the main content / primary label to display inside this list item

@Composable
public static final void ListItem(
    @NonNull Function0<Unit> onClick,
    @NonNull Modifier modifier,
    @Composable Function0<Unit> supportingLabel,
    @Composable Function0<Unit> leadingIcon,
    @Composable Function0<Unit> trailingIcon,
    @NonNull Shape shape,
    @NonNull Color color,
    @NonNull Color contentColor,
    BorderStroke border,
    @NonNull PaddingValues contentPadding,
    MutableInteractionSource interactionSource,
    @Composable @NonNull Function0<Unit> content
)

ListItem is a component used to represent a single item in a androidx.xr.glimmer.list.VerticalList. A ListItem has a primary label content, and may also have any combination of supportingLabel, leadingIcon, and trailingIcon. The supporting label is displayed below the primary label and can be used to provide additional information. A ListItem fills the maximum width available by default.

This ListItem is focusable and clickable - see the other ListItem overload for a ListItem that is only focusable.

A simple clickable ListItem with just a primary label:

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem(onClick = {}) { Text("Primary Label") }

A clickable ListItem with a primary and supporting label:

import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem(onClick = {}, supportingLabel = { Text("Supporting Label") }) { Text("Primary Label") }

A clickable ListItem with a primary label, a supporting label, and a leading icon:

import androidx.xr.glimmer.Icon
import androidx.xr.glimmer.ListItem
import androidx.xr.glimmer.Text

ListItem(
    onClick = {},
    supportingLabel = { Text("Supporting Label") },
    leadingIcon = { Icon(FavoriteIcon, "Localized description") },
) {
    Text("Primary Label")
}
Parameters
@NonNull Function0<Unit> onClick

called when this list item is clicked

@NonNull Modifier modifier

the Modifier to be applied to this list item

@Composable Function0<Unit> supportingLabel

optional supporting label to be placed underneath the primary label content

@Composable Function0<Unit> leadingIcon

optional leading icon to be placed before the primary label content. This is typically an Icon.

@Composable Function0<Unit> trailingIcon

optional trailing icon to be placed after the primary label content. This is typically an Icon.

@NonNull Shape shape

the Shape used to clip this list item, and also used to draw the background and border

@NonNull Color color

background color of this list item

@NonNull Color contentColor

content color used by components inside content, and supportingLabel.

BorderStroke border

the border to draw around this list item

@NonNull PaddingValues contentPadding

the spacing values to apply internally between the container and the content

MutableInteractionSource interactionSource

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this list item. You can use this to change the list item's appearance or preview the list item in different states. Note that if null is provided, interactions will still happen internally.

@Composable @NonNull Function0<Unit> content

the main content / primary label to display inside this list item