Skip to content

Badge ​

A count or dot badge. Use it standalone, or wrap content to float the mark at the content's top-right corner (e.g. over an icon). max caps the displayed count to ${max}+.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismBadge

Basic usage ​

kotlin
PrismBadge(count = 5)

Dot and overflow ​

kotlin
PrismBadge(dot = true, tone = PrismTone.Success)
PrismBadge(count = 250, max = 99) // renders "99+"

Floating over content ​

When content is provided, the badge floats at its top-right corner.

kotlin
PrismBadge(count = 3) {
    PrismIcon(PrismIcons.Info, contentDescription = "Notifications")
}

API ​

ParameterTypeDefaultDescription
modifierModifierModifierLayout/visual modifier (applied to the wrapper when content is set).
countInt?nullNumeric value to display; null with dot = false renders a dot.
dotBooleanfalseRender an 8dp text-less dot instead of a count pill.
maxInt99Largest count shown before overflowing to ${max}+.
tonePrismTonePrismTone.DangerSemantic color of the badge fill.
content(@Composable () -> Unit)?nullOptional anchor; the badge floats at its top-right corner.

Enum ​

kotlin
enum class PrismTone { Accent, Success, Warning, Danger, Neutral }

All components assume an enclosing PrismTheme { }. See Styling for theming details.

Released under the MIT License.