Pill
Pill component is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a button by at minimum providing a title and an action. The action is either a method or closure property that does something when a user clicks the button. The label is a String that describes an attribute or unit of data.
Parameters
The text to be displayed.
Modifier to be applied to the Pill.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}Pill component is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a button by at minimum providing a title and an action. The action is either a method or closure property that does something when a user clicks the button. The label is a String that describes an attribute or unit of data.
Parameters
The text to be displayed.
Modifier to be applied to the Pill.
Leading item to be displayed, Icons, Thumbnails.
Resources object to query the image file from.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}Pill component with Icon and Badge is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a Pill with a badge by at minimum providing a title, a trailingIcon, a badge value, and an action. The action is either a method or closure property that does something when a user clicks the pill. The label is a String that describes an attribute or unit of data. The icon is a DrawableRes id and must point to either fully rasterized images (ex. PNG or JPG files) or VectorDrawable xml assets, and the value the amount if selected items.
Parameters
The text to be displayed.
Allows quantity data to help communicate the amount of selected items, it will only show if selected and value is different
Resources object to query the image file from. from zero.
Modifier to be applied to the Pill.
Leading item to be displayed, Icons, Thumbnails.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}Deprecated
Use function with leadingItem and trailingIconId
Replace with
Pill(label = label, modifier = modifier, enabled = enabled, size = size, selected = selected, leadingItem = if (iconPosition == IconPosition.Horizontal.Leading) PillLeadingItem.Icon(iconId) else null, trailingIconId = if (iconPosition == IconPosition.Horizontal.Trailing) iconId else null, interactionSource = interactionSource, onClick = onClick)Pill component with Icon is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a Pill with an icon by at minimum providing a title, an icon, and an action. The action is either a method or closure property that does something when a user clicks the pill. The label is a String that describes an attribute or unit of data. The icon is a DrawableRes id and must point to either fully rasterized images (ex. PNG or JPG files) or VectorDrawable xml assets.
Parameters
The text to be displayed.
Resources object to query the image file from.
Modifier to be applied to the Pill.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
IconPosition.Horizontal indicates where the icon will be displayed
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}Deprecated
Use function with leadingItem
Replace with
Pill(label = label, modifier = modifier, enabled = enabled, size = size, selected = selected, leadingItem = PillLeadingItem.Thumbnail(thumbnail), interactionSource = interactionSource, trailingIconId = null, onClick = onClick)Pill component with Thumbnail is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a Pill with a thumbnail by at minimum providing a title, a thumbnail, and an action. The action is either a method or closure property that does something when a user clicks the pill. The label is a String that describes an attribute or unit of data. The thumbnail is Painter with an image data to help communicate the pill value.
Parameters
The text to be displayed.
Painter to draw inside the Pill.
Modifier to be applied to the Pill.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}Deprecated
Use function with leadingItem and trailingIconId
Replace with
Pill(label = label, modifier = modifier, enabled = enabled, size = size, selected = selected, leadingItem = null, trailingIconId = iconId, badgeValue = badgeValue, interactionSource = interactionSource, onClick = onClick)Pill component with Icon and Badge is a button that represents an attribute or unit of data. It's built on top of androidx.compose.material.Button and comes with predefined appearance based on Skapa design and guidelines.
You create a Pill with an icon by at minimum providing a title, an icon, a value, and an action. The action is either a method or closure property that does something when a user clicks the pill. The label is a String that describes an attribute or unit of data. The icon is a DrawableRes id and must point to either fully rasterized images (ex. PNG or JPG files) or VectorDrawable xml assets, and the value the amount if selected items.
Parameters
The text to be displayed.
Resources object to query the image file from.
Allows quantity data to help communicate the amount of selected items, it will only show if selected and value is different from zero.
Modifier to be applied to the Pill.
Controls the enabled state of the button. When false, this button will not be clickable.
PillSize defines the size of the pill. The default value is PillSize.Medium.
Controls to display state of the pill.
The MutableInteractionSource representing the stream of Interactions for this component.
Will be called when the user clicks the Pill.
See also
Samples
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.R
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Pill
import net.ikea.skapa.ui.components.PillSize
fun main() {
//sampleStart
SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
var pillState by remember { mutableStateOf(true) }
Column(verticalArrangement = Arrangement.spacedBy(SkapaSpacing.space50)) {
// No Icons
Pill(
label = "Category",
selected = pillState
) {
pillState = !pillState
}
// Icon
Pill(
label = "Category",
iconId = R.drawable.ic_image_fallback_image,
size = PillSize.Medium,
selected = pillState
) { pillState = !pillState }
// Thumbnail
Pill(
label = "Category",
thumbnail = painterResource(id = R.drawable.ic_image_fallback_image),
size = PillSize.Small,
selected = pillState
) {
pillState = !pillState
}
}
}
//sampleEnd
}