
Enhances Jetpack Compose applications with customizable Toast notifications, enabling easy display of transient messages across Android, iOS, and desktop platforms. Offers various toast types like SUCCESS, ERROR, WARNING, and INFO.
Compose Toast provides a simple and customizable implementation of toast notifications for Jetpack
Compose Multiplatform applications.
It lets you display transient messages across Android, iOS, JVM/desktop, JS, and WASM from
shared Compose UI.
This repository contains:
ComposeToast: the main Compose Multiplatform UI library (
io.github.the-best-is-best:compose_toast)toastKMP: a lower‑level Kotlin Multiplatform module that shows native toasts per
platformsimple: sample apps demonstrating how to use the libraryBoth libraries are available on mavenCentral().
In your top‑level repositories:
repositories {
mavenCentral()
google()
}implementation("io.github.the-best-is-best:compose_toast:2.1.2")implementation("io.github.the-best-is-best:compose_toast:2.1.1")In a Kotlin Multiplatform project you typically add it to commonMain:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.the-best-is-best:compose_toast:2.1.2")
}
}
}If you only need the native toast abstraction (without the Compose UI), add the toast_kmp
artifact:
dependencies {
implementation("io.github.the-best-is-best:toast_kmp:3.0.0")
}In a KMP source-set:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.the-best-is-best:toast_kmp:3.0.0")
}
}
}This exposes the low-level NativeShowToast APIs and helpers described in toastKMP/README.md.
val stateToast = rememberAdvToastStates()
val coroutineScope = rememberCoroutineScope()
Box(modifier = Modifier.fillMaxSize()) {
// Default styled toast overlay
AdvToast.MakeToast(
state = stateToast,
toastType = EnumToastType.INFO,
paddingBottom = 50
)
// Your screen content
Column(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.safeDrawing)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
ElevatedButton(
onClick = {
coroutineScope.launch {
stateToast.show("Hello toast!")
}
}
) {
Text(text = "Show Toast")
}
}
}enum class EnumToastType {
SUCCESS, ERROR, WARNING, INFO
}Pass the desired type to AdvToast.MakeToast to get the corresponding styling.
You can show a custom Compose layout while still using the same state object:
val stateCustomToast = rememberAdvToastStates()
AdvToast.MakeCustomToast(
state = stateCustomToast,
textColor = Color.Black,
paddingTop = 50,
modifier = Modifier
.padding(horizontal = 50.dp)
.background(Color.Cyan, shape = RoundedCornerShape(8.dp)),
align = Arrangement.Top,
)Trigger it from your UI:
coroutineScope.launch {
stateCustomToast.show("Custom toast")
}Compose Toast also exposes a higher‑level multiplatform API that delegates to native toast
implementations under the hood (powered by the toastKMP module).
From shared code:
NativeShowToastCMP.show(
"Native toast message",
NativeToastTypeCMP.LONG
)This will:
Toast
For advanced/low‑level usage (e.g., calling native APIs directly from per‑platform code), see the *
*toastKMP/README.md**.
On JVM/desktop, the library can display the app logo if an image is added at:
resources/images/app_logo.pngThe helper APIs in toastKMP (getAppLogo/getAppLogoIOS) are used internally to render the logo
when present.
ComposeToast – published Compose Multiplatform UI library (
io.github.the-best-is-best:compose_toast)toastKMP – published KMP module with platform‑specific native toast and app‑logo
helpers (io.github.the-best-is-best:toast_kmp)simple – sample MPP project showing:
You can open the project in Android Studio / IntelliJ IDEA with KMP support and run the sample targets.
Licensed under the Apache License, Version 2.0.
See the LICENSE file for full details.
Compose Toast provides a simple and customizable implementation of toast notifications for Jetpack
Compose Multiplatform applications.
It lets you display transient messages across Android, iOS, JVM/desktop, JS, and WASM from
shared Compose UI.
This repository contains:
ComposeToast: the main Compose Multiplatform UI library (
io.github.the-best-is-best:compose_toast)toastKMP: a lower‑level Kotlin Multiplatform module that shows native toasts per
platformsimple: sample apps demonstrating how to use the libraryBoth libraries are available on mavenCentral().
In your top‑level repositories:
repositories {
mavenCentral()
google()
}implementation("io.github.the-best-is-best:compose_toast:2.1.2")implementation("io.github.the-best-is-best:compose_toast:2.1.1")In a Kotlin Multiplatform project you typically add it to commonMain:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.the-best-is-best:compose_toast:2.1.2")
}
}
}If you only need the native toast abstraction (without the Compose UI), add the toast_kmp
artifact:
dependencies {
implementation("io.github.the-best-is-best:toast_kmp:3.0.0")
}In a KMP source-set:
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.the-best-is-best:toast_kmp:3.0.0")
}
}
}This exposes the low-level NativeShowToast APIs and helpers described in toastKMP/README.md.
val stateToast = rememberAdvToastStates()
val coroutineScope = rememberCoroutineScope()
Box(modifier = Modifier.fillMaxSize()) {
// Default styled toast overlay
AdvToast.MakeToast(
state = stateToast,
toastType = EnumToastType.INFO,
paddingBottom = 50
)
// Your screen content
Column(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.safeDrawing)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
ElevatedButton(
onClick = {
coroutineScope.launch {
stateToast.show("Hello toast!")
}
}
) {
Text(text = "Show Toast")
}
}
}enum class EnumToastType {
SUCCESS, ERROR, WARNING, INFO
}Pass the desired type to AdvToast.MakeToast to get the corresponding styling.
You can show a custom Compose layout while still using the same state object:
val stateCustomToast = rememberAdvToastStates()
AdvToast.MakeCustomToast(
state = stateCustomToast,
textColor = Color.Black,
paddingTop = 50,
modifier = Modifier
.padding(horizontal = 50.dp)
.background(Color.Cyan, shape = RoundedCornerShape(8.dp)),
align = Arrangement.Top,
)Trigger it from your UI:
coroutineScope.launch {
stateCustomToast.show("Custom toast")
}Compose Toast also exposes a higher‑level multiplatform API that delegates to native toast
implementations under the hood (powered by the toastKMP module).
From shared code:
NativeShowToastCMP.show(
"Native toast message",
NativeToastTypeCMP.LONG
)This will:
Toast
For advanced/low‑level usage (e.g., calling native APIs directly from per‑platform code), see the *
*toastKMP/README.md**.
On JVM/desktop, the library can display the app logo if an image is added at:
resources/images/app_logo.pngThe helper APIs in toastKMP (getAppLogo/getAppLogoIOS) are used internally to render the logo
when present.
ComposeToast – published Compose Multiplatform UI library (
io.github.the-best-is-best:compose_toast)toastKMP – published KMP module with platform‑specific native toast and app‑logo
helpers (io.github.the-best-is-best:toast_kmp)simple – sample MPP project showing:
You can open the project in Android Studio / IntelliJ IDEA with KMP support and run the sample targets.
Licensed under the Apache License, Version 2.0.
See the LICENSE file for full details.