Skip to content

Badge - Android ​

Badges are used to highlight a relevant piece of information, like status or category.

AndroidreleasedElementsreleasediOSreleasedReactreleasedVuereleased

Android ​

Syntax ​

kotlin
@Composable
fun WarpBadge(
    modifier: Modifier = Modifier,
    text: String,
    style: WarpBadgeStyle = WarpBadgeStyle.Neutral,
    alignmentStyle: WarpBadgeAlignment = WarpBadgeAlignment.None,
    icon: WarpIconResource? = null
)

The default style for the badge is Neutral.

kotlin
WarpBadge(
    text = "Success",
    style = WarpBadgeStyle.Success,
    alignment = Alignment.BottomStart
    )

There are a variety of styles and alignments supported for the badge component:

kotlin
WarpBadgeStyle {
    Info,
    Success,
    Warning,
    Error,
    Disabled,
    Neutral,
    Sponsored,
    Price
}

WarpBadgeAlignment {
    None,
    TopStart,
    TopEnd,
    BottomStart,
    BottomEnd
}

Legacy support ​

To support layouts still written in xml the WarpBadge can be used as a custom view.

xml
<com.schibsted.nmp.warp.components.legacy.WarpBadgeView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Warp badge!"
    app:alignmentStyle="topEnd"
    app:warpBadgeStyle="sponsored" />

Parameters ​

Required props ​

NameTypeDefaultDescription
textStringThe text to be displayed on the badge

Optional Props ​

NameTypeDefaultDescription
modifierModifierModifierSets the modifier for the badge
styleWarpBadgeStyle.Neutral WarpBadgeStyle.Info WarpBadgeStyle.Success WarpBadgeStyle.Warning WarpBadgeStyle.Error WarpBadgeStyle.Disabled WarpBadgeStyle.Sponsored WarpBadgeStyle.PriceWarpBadgeStyle.NeutralSets the appearance of the badge
alignmentStyleWarpBadgeAlignment.None WarpBadgeAlignment.TopStart WarpBadgeAlignment.TopEnd WarpBadgeAlignment.BottomStart WarpBadgeAlignment.BottomEndWarpBadgeAlignment.NoneSets the alignment style for the badge
iconWarpIconResource?nullSets the icon for the badge

Questions? ​

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system