Badge

Badge

A small overlay for showing notifications, counts, or status indicators on other UI elements.


Installation

./gradlew lumo --add Badge

Usage

Basic Example

// just a dot
Badge()
 
// with content
Badge {
    Text("9+")
}

BadgedBox Example

BadgedBox(
    badge = {
        Badge(
            containerColor = AppTheme.colors.primary
        ) {
            Text("NEW")
        }
    },
    content = {
        Icon(Icons.Default.Email, "Messages")
    }
)

API Documentation

BadgedBox

The BadgedBox composable displays a badge in the top-end position of its content.

Parameters

ParameterTypeDescription
badge@Composable BoxScope.() -> UnitBadge content to be displayed
modifierModifierModifier for the container
content@Composable BoxScope.() -> UnitMain content that the badge will be attached to

Badge

The Badge composable creates the actual badge element that can be empty (dot) or contain content.

Parameters

ParameterTypeDefaultDescription
modifierModifierModifierModifier for the badge
containerColorColorBadgeDefaults.containerColorBackground color of the badge
contentColorColorcontentColorFor(containerColor)Color of the badge content
content@Composable (RowScope.() -> Unit)?nullOptional content inside the badge