ListViewItem
List View Item consists of one or more items and can contain actions represented by Icons and text. The List View Item is available in three sizes. Small for one line text, medium and large.
Present your lists in a way that makes it easy to identify a specific item in a collection and take action. Always present Icons, text and actions in a uniform format.
Parameters
The primary text of the list view item
Modifier to be applied to the list view item
The secondary text of the list view item is usually used as an item description.
The leading supporting visual of the list view item
The trailing control, icon, switch, checkbox or radiobutton.
The trailing meta text to display a quantity of the item. Uses AccessibleLabel to provide a content description for accessibility.
Extra addons to be displayed under the item description.
ListViewItemSize defines the minimum height of the list view item.
The padding applied to the content of this menu item.
dictates whether the title is regular with ListViewItemTextStyle.Regular and bold with ListViewItemTextStyle.Emphasised.
whether the component is enabled or grayed out.
The MutableInteractionSource representing the stream of Interactions for this component.
will be called when the user clicks on the list view item
See also
Samples
import android.widget.Toast
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.AvatarStyle
import net.ikea.skapa.ui.components.AvatarVariant
import net.ikea.skapa.ui.components.Divider
import net.ikea.skapa.ui.components.ListViewItem
import net.ikea.skapa.ui.components.ListViewItemControls
import net.ikea.skapa.ui.components.ListViewItemImage
import net.ikea.skapa.ui.components.ListViewItemSize
import net.ikea.skapa.ui.components.ListViewItemTextStyle
fun main() {
//sampleStart
val sizes = listOf(ListViewItemSize.Small, ListViewItemSize.Medium, ListViewItemSize.Large)
val title = "Title"
val description = "Description here"
val context = LocalContext.current
val clipboardManager: ClipboardManager = LocalClipboardManager.current
val descriptionToCopy = "1234567890"
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
Column(Modifier.verticalScroll(rememberScrollState())) {
sizes.map { size ->
Text(size.name, fontWeight = FontWeight.Bold, modifier = Modifier.padding(vertical = 10.dp))
Divider()
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Emphasised) {}
ListViewItem(title = title, description = description, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(
title = title,
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Icon(R.drawable.ic_switch_checkmark, null)
) {}
if (size != ListViewItemSize.Small) {
ListViewItem(
title = "$title Image",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.ImageView(painterResource(R.drawable.ic_button_danger), null)
) {}
}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
quantityLabel = "(30)",
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.RadioButton(true)
) {}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.Arrow
) {}
ListViewItem(
title = "$title",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.LinkOut("Open in browser")
) {}
ListViewItem(
title = "Copy",
description = descriptionToCopy,
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.Copy("Copy number"),
onClick = {
clipboardManager.setText(AnnotatedString(descriptionToCopy))
Toast.makeText(context, "$descriptionToCopy has been copied", Toast.LENGTH_LONG).show()
}
)
ListViewItem(
title = "Avatar Image",
description = description,
// List view item size maps automatically to avatar size ListViewItemSize -> AvatarSize
// Small -> XSmall, Medium -> Small, Large -> Medium (56px until we have a 48px size avatar)
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Avatar(
// Check avatar documentation for more details on Variant, Style and Static params
variant = AvatarVariant.Text("AI"),
style = AvatarStyle.Secondary
),
onClick = { /* Do something*/ }
)
}
}
}
//sampleEnd
}List View Item consists of one or more items and can contain actions represented by Icons and text. The List View Item is available in three sizes. Small for one line text, medium and large.
Present your lists in a way that makes it easy to identify a specific item in a collection and take action. Always present Icons, text and actions in a uniform format.
Parameters
The primary text of the list view item
Modifier to be applied to the list view item
The secondary text of the list view item is usually used as an item description.
The leading supporting visual of the list view item
The trailing control, icon, switch, checkbox or radiobutton.
The trailing meta text to display a quantity of the item.
Extra addons to be displayed under the item description.
ListViewItemSize defines the minimum height of the list view item.
The padding applied to the content of this menu item.
dictates whether the title is regular with ListViewItemTextStyle.Regular and bold with ListViewItemTextStyle.Emphasised.
whether the component is enabled or grayed out.
The MutableInteractionSource representing the stream of Interactions for this component.
will be called when the user clicks on the list view item
See also
Samples
import android.widget.Toast
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.AvatarStyle
import net.ikea.skapa.ui.components.AvatarVariant
import net.ikea.skapa.ui.components.Divider
import net.ikea.skapa.ui.components.ListViewItem
import net.ikea.skapa.ui.components.ListViewItemControls
import net.ikea.skapa.ui.components.ListViewItemImage
import net.ikea.skapa.ui.components.ListViewItemSize
import net.ikea.skapa.ui.components.ListViewItemTextStyle
fun main() {
//sampleStart
val sizes = listOf(ListViewItemSize.Small, ListViewItemSize.Medium, ListViewItemSize.Large)
val title = "Title"
val description = "Description here"
val context = LocalContext.current
val clipboardManager: ClipboardManager = LocalClipboardManager.current
val descriptionToCopy = "1234567890"
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
Column(Modifier.verticalScroll(rememberScrollState())) {
sizes.map { size ->
Text(size.name, fontWeight = FontWeight.Bold, modifier = Modifier.padding(vertical = 10.dp))
Divider()
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Emphasised) {}
ListViewItem(title = title, description = description, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(
title = title,
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Icon(R.drawable.ic_switch_checkmark, null)
) {}
if (size != ListViewItemSize.Small) {
ListViewItem(
title = "$title Image",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.ImageView(painterResource(R.drawable.ic_button_danger), null)
) {}
}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
quantityLabel = "(30)",
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.RadioButton(true)
) {}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.Arrow
) {}
ListViewItem(
title = "$title",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.LinkOut("Open in browser")
) {}
ListViewItem(
title = "Copy",
description = descriptionToCopy,
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.Copy("Copy number"),
onClick = {
clipboardManager.setText(AnnotatedString(descriptionToCopy))
Toast.makeText(context, "$descriptionToCopy has been copied", Toast.LENGTH_LONG).show()
}
)
ListViewItem(
title = "Avatar Image",
description = description,
// List view item size maps automatically to avatar size ListViewItemSize -> AvatarSize
// Small -> XSmall, Medium -> Small, Large -> Medium (56px until we have a 48px size avatar)
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Avatar(
// Check avatar documentation for more details on Variant, Style and Static params
variant = AvatarVariant.Text("AI"),
style = AvatarStyle.Secondary
),
onClick = { /* Do something*/ }
)
}
}
}
//sampleEnd
}List View Item consists of one or more items and can contain actions represented by Icons and text. The List View Item is available in three sizes. Small for one line text, medium and large.
Present your lists in a way that makes it easy to identify a specific item in a collection and take action. Always present Icons, text and actions in a uniform format.
Parameters
The primary text of the list view item
Modifier to be applied to the list view item
The secondary text of the list view item is usually used as an item description.
The leading supporting visual of the list view item
The trailing control, icon, switch, checkbox or radiobutton.
The trailing components that complement the item information.
Extra addons to be displayed under the item description.
ListViewItemSize defines the minimum height of the list view item.
The padding applied to the content of this menu item.
dictates whether the title is regular with ListViewItemTextStyle.Regular and bold with ListViewItemTextStyle.Emphasised.
whether the component is enabled or grayed out.
The MutableInteractionSource representing the stream of Interactions for this component.
will be called when the user clicks on the list view item
See also
Samples
import android.widget.Toast
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.AvatarStyle
import net.ikea.skapa.ui.components.AvatarVariant
import net.ikea.skapa.ui.components.Divider
import net.ikea.skapa.ui.components.ListViewItem
import net.ikea.skapa.ui.components.ListViewItemControls
import net.ikea.skapa.ui.components.ListViewItemImage
import net.ikea.skapa.ui.components.ListViewItemSize
import net.ikea.skapa.ui.components.ListViewItemTextStyle
fun main() {
//sampleStart
val sizes = listOf(ListViewItemSize.Small, ListViewItemSize.Medium, ListViewItemSize.Large)
val title = "Title"
val description = "Description here"
val context = LocalContext.current
val clipboardManager: ClipboardManager = LocalClipboardManager.current
val descriptionToCopy = "1234567890"
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
Column(Modifier.verticalScroll(rememberScrollState())) {
sizes.map { size ->
Text(size.name, fontWeight = FontWeight.Bold, modifier = Modifier.padding(vertical = 10.dp))
Divider()
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Emphasised) {}
ListViewItem(title = title, description = description, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(
title = title,
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Icon(R.drawable.ic_switch_checkmark, null)
) {}
if (size != ListViewItemSize.Small) {
ListViewItem(
title = "$title Image",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.ImageView(painterResource(R.drawable.ic_button_danger), null)
) {}
}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
quantityLabel = "(30)",
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.RadioButton(true)
) {}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.Arrow
) {}
ListViewItem(
title = "$title",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.LinkOut("Open in browser")
) {}
ListViewItem(
title = "Copy",
description = descriptionToCopy,
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.Copy("Copy number"),
onClick = {
clipboardManager.setText(AnnotatedString(descriptionToCopy))
Toast.makeText(context, "$descriptionToCopy has been copied", Toast.LENGTH_LONG).show()
}
)
ListViewItem(
title = "Avatar Image",
description = description,
// List view item size maps automatically to avatar size ListViewItemSize -> AvatarSize
// Small -> XSmall, Medium -> Small, Large -> Medium (56px until we have a 48px size avatar)
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Avatar(
// Check avatar documentation for more details on Variant, Style and Static params
variant = AvatarVariant.Text("AI"),
style = AvatarStyle.Secondary
),
onClick = { /* Do something*/ }
)
}
}
}
//sampleEnd
}List View Item consist of one or more items and can contain actions represented by Icons and text. The List View Item is available in three sizes. Small for one line text, medium and large.
Present your lists in a way that makes it easy to identify a specific item in a collection and take action. Always present Icons, text and actions in a uniform format.
This function provides the backbone to create a List View Item using custom Composables. For most of the cases we recommend using the ListViewItem without Composables instead of this function.
Parameters
The primary text of the list view item
Modifier to be applied to the list view item
The secondary text of the list view item is usually used as an item description.
The leading supporting visual of the list view item
The trailing meta text, icon, switch, checkbox or radiobutton.
Extra addons to be displayed under the item description.
ListViewItemSize defines the minimum height of the list view item.
The padding applied to the content of this menu item
whether the component is enabled or grayed out.
The MutableInteractionSource representing the stream of Interactions for this component.
will be called when the user clicks on the list view item
See also
Samples
import android.widget.Toast
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.AvatarStyle
import net.ikea.skapa.ui.components.AvatarVariant
import net.ikea.skapa.ui.components.Divider
import net.ikea.skapa.ui.components.ListViewItem
import net.ikea.skapa.ui.components.ListViewItemControls
import net.ikea.skapa.ui.components.ListViewItemImage
import net.ikea.skapa.ui.components.ListViewItemSize
import net.ikea.skapa.ui.components.ListViewItemTextStyle
fun main() {
//sampleStart
val sizes = listOf(ListViewItemSize.Small, ListViewItemSize.Medium, ListViewItemSize.Large)
val title = "Title"
val description = "Description here"
val context = LocalContext.current
val clipboardManager: ClipboardManager = LocalClipboardManager.current
val descriptionToCopy = "1234567890"
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
Column(Modifier.verticalScroll(rememberScrollState())) {
sizes.map { size ->
Text(size.name, fontWeight = FontWeight.Bold, modifier = Modifier.padding(vertical = 10.dp))
Divider()
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(title = title, size = size, textStyle = ListViewItemTextStyle.Emphasised) {}
ListViewItem(title = title, description = description, size = size, textStyle = ListViewItemTextStyle.Regular) {}
ListViewItem(
title = title,
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Icon(R.drawable.ic_switch_checkmark, null)
) {}
if (size != ListViewItemSize.Small) {
ListViewItem(
title = "$title Image",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.ImageView(painterResource(R.drawable.ic_button_danger), null)
) {}
}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
quantityLabel = "(30)",
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.RadioButton(true)
) {}
ListViewItem(
title = "$title PaymentLogo",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.PaymentLogo(painterResource(id = R.drawable.ic_switch_checkmark), null),
trailingControl = ListViewItemControls.Arrow
) {}
ListViewItem(
title = "$title",
description = description,
size = size,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.LinkOut("Open in browser")
) {}
ListViewItem(
title = "Copy",
description = descriptionToCopy,
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
trailingControl = ListViewItemControls.Copy("Copy number"),
onClick = {
clipboardManager.setText(AnnotatedString(descriptionToCopy))
Toast.makeText(context, "$descriptionToCopy has been copied", Toast.LENGTH_LONG).show()
}
)
ListViewItem(
title = "Avatar Image",
description = description,
// List view item size maps automatically to avatar size ListViewItemSize -> AvatarSize
// Small -> XSmall, Medium -> Small, Large -> Medium (56px until we have a 48px size avatar)
size = ListViewItemSize.Medium,
textStyle = ListViewItemTextStyle.Regular,
leadingImage = ListViewItemImage.Avatar(
// Check avatar documentation for more details on Variant, Style and Static params
variant = AvatarVariant.Text("AI"),
style = AvatarStyle.Secondary
),
onClick = { /* Do something*/ }
)
}
}
}
//sampleEnd
}