Components
Badge
Status labels, notification count pills, verification icons, and widget-anchored badges
Status labels, notification count pills, verification icons, and widget-anchored badges.
Import from com.ux4g.designsystemv1.components.Ux4gBadge.
Interactive Preview
Ux4gBadgeJetpack Compose
Count
Icon
Dot
Verification
Kotlin Usage
import androidx.compose.runtime.Composable
import com.ux4g.designsystemv1.components.Ux4gBadge
import com.ux4g.designsystemv1.components.Ux4gBadgeType
import com.ux4g.designsystemv1.components.Ux4gBadgeLimit
import com.ux4g.designsystemv1.foundation.Ux4gColors
@Composable
fun BadgeExample() {
Ux4gBadge(
type = Ux4gBadgeType.Label("VERIFIED"),
containerColor = Ux4gColors.green600
)
}Parameters
Ux4gBadge Props
| Prop | Type | Description | Default |
|---|---|---|---|
type * | Ux4gBadgeType | Type configuration: Dot, Count, Label, Icon, or ReadyToUse. | — |
modifier | Modifier | Compose layout modifier. | Modifier |
containerColor | Color | Background fill color of the badge container. | Ux4gColors.primary |
contentColor | Color | Color for text or icon inside the badge. | Ux4gColors.white |
showBorder | Boolean | Whether to display outer boundary stroke. | false |
borderColor | Color | Stroke outline color when showBorder = true. | Ux4gColors.neutral300 |
alignment | Ux4gBadgeAlignment | Corner anchor placement when wrapping child content (TopEnd, TopStart, BottomEnd, BottomStart). | Ux4gBadgeAlignment.TopEnd |
content | (@Composable () -> Unit)? | Optional child composable to anchor the badge overlay upon. | null |
Ux4gBadgeType Sealed Class Variants
| Variant | Parameters | Description |
|---|---|---|
Dot | size: Dp = 8.dp | Small circular presence or unread indicator dot. |
Count / Text | count: Int, limit: Ux4gBadgeLimit | Numeric count badge displaying formatted values (e.g. 9+, 99+). |
Label | text: String | Capsule pill displaying short capitalized label text. |
Icon | iconRes: Int or icon: Ux4gIcon | Small icon badge inside rounded container. |
ReadyToUse | resource: Ux4gBadgeResource | Pre-styled official badges (Verification, Star, Shield). |