
Lightweight, customizable toast-style notifications with timed, persistent, dismissible and clickable behaviors, swipe gestures, animated transitions, and flexible visual customization via slots and host config.
Lightweight, customizable toast-style notifications for Compose Multiplatform.
Koasty gives Compose Multiplatform applications a shared notification API across Android, iOS, desktop, and web. Show a short message from common code, let Koasty handle its lifetime and dismissal, and customize the visuals when your product needs a distinct style.
Full documentation lives in docs/.
[!NOTE] Koasty is in early development. The API may change before the first stable release. Feedback, bug reports, and contributions are welcome.
| Platform | Target |
|---|---|
| Android | android |
| iOS devices | iosArm64 |
| iOS Simulator on Apple Silicon | iosSimulatorArm64 |
| Desktop | jvm |
| Web |
js and wasmJs
|
Koasty is configured for publication under:
commonMain.dependencies {
implementation("io.github.deference3:koasty:0.1.0")
}Create and remember one KoastManager, then place KoastyProvider around your application content. The provider renders notifications above its content.
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.deference.koasty.KoastManager
import com.deference.koasty.KoastyProvider
@Composable
fun App() {
val koastManager = remember { KoastManager() }
KoastyProvider(koastManager = koastManager) {
Button(
onClick = {
koastManager.show(
title = "Saved",
message = "Your changes are ready."
)
}
) {
Text("Show koast")
}
}
}The manager exposes focused methods for common notification behavior:
// Disappears automatically after 3.5 seconds by default.
koastManager.show("Uploaded", "Your image is now available.")
// Custom duration.
koastManager.show(
title = "Connected",
duration = 5.seconds //accepts kotlin Duration
)
// Remains until swiped away or dismissed in code.
koastManager.showUntilDismissed(
title = "You're offline",
message = "Some features may be unavailable."
)
// Can only be dismissed in code.
koastManager.showPersistent(
title = "Uploading",
message = "Please keep the app open."
)
koastManager.dismiss()Clickable notifications are supported as well:
koastManager.showClickable(
title = "Update available",
message = "Tap to view the release notes.",
onClick = { openReleaseNotes() }
)Unless you give them a key (see below), koasts never replace each other. Each call to show (or any other show* method) adds a koast to the back of a first-in, first-out queue. The koast at the front is the only one that counts down its duration and responds to swipes and clicks. When it is dismissed, the next koast takes its place.
koastManager.show("Uploading", "1 of 3")
koastManager.show("Uploading", "2 of 3") // waits for the first
koastManager.show("Uploading", "3 of 3") // waits for the second
koastManager.dismiss() // dismiss the koast in front
koastManager.dismiss(id) // dismiss a specific koast, even one still queued
koastManager.dismissAll() // clear the front koast and the whole queue
koastManager.queue // pending koasts, front firstEvery show* method returns the koast's id. A persistent or until-dismissed koast keeps everything behind it waiting until you dismiss it.
The queue has one lane per position. A koast whose style puts it somewhere else, such as a bottom toast, waits only for koasts at that same position. dismiss() removes the oldest koast overall.
Pass a key to update a koast instead of queueing another one. If a koast with the same key is still showing or waiting, the new one replaces it in place: same queue position, same id, new content, and its duration starts over. Once the keyed koast is gone, the next call with that key queues a fresh one.
koastManager.showPersistent("Uploading", "0%", key = "upload")
koastManager.showPersistent("Uploading", "40%", key = "upload") // updates the same koast
koastManager.show("Upload complete", key = "upload") // replaces it, then times outEvery show* method accepts key. Koasts with different keys, or with no key, queue as usual.
By default the host shows one koast at a time (KoastDisplayMode.Sequential, which is a Stacked preset with maxVisible = 1 and no peek, scale or expand handle). To layer queued koasts behind the front one like a deck of cards, use KoastDisplayMode.Stacked:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(
displayMode = KoastDisplayMode.Stacked(
maxVisible = 3, // cards drawn, including the front one
peekOffset = 10.dp, // how far each card peeks out behind
scaleStep = 0.05f // how much smaller each card behind is
)
)
) {
AppContent()
}The queue order is the same in both modes. The front card is the oldest koast. When it leaves, the next card moves forward and the next queued koast joins at the back.
A stacked host shows a handle next to the stack whenever more than one koast is queued. Clicking it spreads the whole queue out as a scrollable list, and clicking it again collapses it back into a stack. The default handle reads "n more koasts", where n counts every queued koast behind the front one.
While the stack is expanded:
The stack collapses by itself once only one koast is left. A koast styled with stackable = false, such as KoastStyle.Toast, is never stacked: while it is queued, its position shows one koast at a time. Pass expandable = false to KoastDisplayMode.Stacked to hide the handle, and expandedSpacing to change the gap between cards in the list.
Provide stackHandle to draw your own handle. Koasty makes it clickable for you; call state.toggle() if your handle has its own button:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(displayMode = KoastDisplayMode.Stacked()),
stackHandle = { state ->
Text(if (state.expanded) "Collapse" else "+${state.moreCount}")
}
) {
AppContent()
}Use KoastyHostConfig to adapt the default notification to your design system:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(
containerColor = MaterialTheme.colorScheme.inverseSurface,
contentColor = MaterialTheme.colorScheme.inverseOnSurface,
shape = RoundedCornerShape(16.dp),
shadowElevation = 12.dp,
horizontalSwipeEnabled = true,
swipeUpEnabled = true
)
) {
AppContent()
}For complete visual control, pass koastContent and render the KoastRequest yourself. Koasty still draws the container and handles position, gestures and animations. To add a leading icon while keeping the standard title and message, combine your content with DefaultKoastContent:
val config = KoastyHostConfig()
KoastyProvider(
koastManager = koastManager,
config = config,
koastContent = { koast ->
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Rounded.Notifications, contentDescription = null)
Spacer(Modifier.width(12.dp))
DefaultKoastContent(koast = koast, config = config, modifier = Modifier.weight(1f))
}
}
) {
AppContent()
}Pass a KoastStyle to any show* method to override the host config for that koast alone. Every property is optional; null keeps the host value.
koastManager.showSuccess("Saved") // green
koastManager.showError("Upload failed", "Try again later") // red
koastManager.showWarning("Low storage") // amber
koastManager.showInfo("New version available") // blue
koastManager.showToast("Copied to clipboard") // pill at the bottom center, no swipe
koastManager.show("Saved", style = KoastStyle.Success.copy(shape = RoundedCornerShape(24.dp)))A style can also set the position, size, padding around the card, gestures and the content itself. Give your own style a call site with an extension function, the same way the built-in shortcuts work:
private val PromoStyle = KoastStyle(
position = KoastPosition.TOP_END,
compact = true,
containerColor = Color(0xFF6A1B9A),
contentColor = Color.White,
shape = RoundedCornerShape(topStart = 24.dp, bottomEnd = 24.dp),
outerPadding = PaddingValues(16.dp),
)
fun KoastManager.showPromo(title: String) = show(title, duration = 5.seconds, style = PromoStyle)Each position is its own lane, so a toast at the bottom shows right away even while a persistent banner is up at the top. A keyed koast takes the style of its latest call, so showInfo("Uploading…", key = "upload") followed by showSuccess("Uploaded", key = "upload") turns the same koast green. See per-koast styles for every property.
Clone the repository and use the included Gradle wrapper:
# Android
./gradlew :androidApp:assembleDebug
# Desktop
./gradlew :desktopApp:run
# Web (Wasm)
./gradlew :webApp:wasmJsBrowserDevelopmentRun
# Web (JavaScript)
./gradlew :webApp:jsBrowserDevelopmentRunFor iOS, open iosApp/iosApp.xcodeproj in Xcode and run the application from there.
On Windows, replace ./gradlew with gradlew.bat.
./gradlew :koasty:buildNative Apple binaries must be built on macOS.
koasty/ Compose Multiplatform library
shared/ Shared UI for the sample applications
androidApp/ Android sample entry point
desktopApp/ Desktop sample entry point
webApp/ JavaScript and Wasm sample entry points
iosApp/ iOS sample entry point
docs/ Documentation site (Docs7)
Contributions of all sizes are welcome.
master.For larger API or behavior changes, open an issue first so the design can be discussed before implementation.
Koasty is distributed under the Apache License 2.0. See the repository license for details.
Built with 💖 for Kotlin Multiplatform / Compose Multiplatform .
Lightweight, customizable toast-style notifications for Compose Multiplatform.
Koasty gives Compose Multiplatform applications a shared notification API across Android, iOS, desktop, and web. Show a short message from common code, let Koasty handle its lifetime and dismissal, and customize the visuals when your product needs a distinct style.
Full documentation lives in docs/.
[!NOTE] Koasty is in early development. The API may change before the first stable release. Feedback, bug reports, and contributions are welcome.
| Platform | Target |
|---|---|
| Android | android |
| iOS devices | iosArm64 |
| iOS Simulator on Apple Silicon | iosSimulatorArm64 |
| Desktop | jvm |
| Web |
js and wasmJs
|
Koasty is configured for publication under:
commonMain.dependencies {
implementation("io.github.deference3:koasty:0.1.0")
}Create and remember one KoastManager, then place KoastyProvider around your application content. The provider renders notifications above its content.
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.deference.koasty.KoastManager
import com.deference.koasty.KoastyProvider
@Composable
fun App() {
val koastManager = remember { KoastManager() }
KoastyProvider(koastManager = koastManager) {
Button(
onClick = {
koastManager.show(
title = "Saved",
message = "Your changes are ready."
)
}
) {
Text("Show koast")
}
}
}The manager exposes focused methods for common notification behavior:
// Disappears automatically after 3.5 seconds by default.
koastManager.show("Uploaded", "Your image is now available.")
// Custom duration.
koastManager.show(
title = "Connected",
duration = 5.seconds //accepts kotlin Duration
)
// Remains until swiped away or dismissed in code.
koastManager.showUntilDismissed(
title = "You're offline",
message = "Some features may be unavailable."
)
// Can only be dismissed in code.
koastManager.showPersistent(
title = "Uploading",
message = "Please keep the app open."
)
koastManager.dismiss()Clickable notifications are supported as well:
koastManager.showClickable(
title = "Update available",
message = "Tap to view the release notes.",
onClick = { openReleaseNotes() }
)Unless you give them a key (see below), koasts never replace each other. Each call to show (or any other show* method) adds a koast to the back of a first-in, first-out queue. The koast at the front is the only one that counts down its duration and responds to swipes and clicks. When it is dismissed, the next koast takes its place.
koastManager.show("Uploading", "1 of 3")
koastManager.show("Uploading", "2 of 3") // waits for the first
koastManager.show("Uploading", "3 of 3") // waits for the second
koastManager.dismiss() // dismiss the koast in front
koastManager.dismiss(id) // dismiss a specific koast, even one still queued
koastManager.dismissAll() // clear the front koast and the whole queue
koastManager.queue // pending koasts, front firstEvery show* method returns the koast's id. A persistent or until-dismissed koast keeps everything behind it waiting until you dismiss it.
The queue has one lane per position. A koast whose style puts it somewhere else, such as a bottom toast, waits only for koasts at that same position. dismiss() removes the oldest koast overall.
Pass a key to update a koast instead of queueing another one. If a koast with the same key is still showing or waiting, the new one replaces it in place: same queue position, same id, new content, and its duration starts over. Once the keyed koast is gone, the next call with that key queues a fresh one.
koastManager.showPersistent("Uploading", "0%", key = "upload")
koastManager.showPersistent("Uploading", "40%", key = "upload") // updates the same koast
koastManager.show("Upload complete", key = "upload") // replaces it, then times outEvery show* method accepts key. Koasts with different keys, or with no key, queue as usual.
By default the host shows one koast at a time (KoastDisplayMode.Sequential, which is a Stacked preset with maxVisible = 1 and no peek, scale or expand handle). To layer queued koasts behind the front one like a deck of cards, use KoastDisplayMode.Stacked:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(
displayMode = KoastDisplayMode.Stacked(
maxVisible = 3, // cards drawn, including the front one
peekOffset = 10.dp, // how far each card peeks out behind
scaleStep = 0.05f // how much smaller each card behind is
)
)
) {
AppContent()
}The queue order is the same in both modes. The front card is the oldest koast. When it leaves, the next card moves forward and the next queued koast joins at the back.
A stacked host shows a handle next to the stack whenever more than one koast is queued. Clicking it spreads the whole queue out as a scrollable list, and clicking it again collapses it back into a stack. The default handle reads "n more koasts", where n counts every queued koast behind the front one.
While the stack is expanded:
The stack collapses by itself once only one koast is left. A koast styled with stackable = false, such as KoastStyle.Toast, is never stacked: while it is queued, its position shows one koast at a time. Pass expandable = false to KoastDisplayMode.Stacked to hide the handle, and expandedSpacing to change the gap between cards in the list.
Provide stackHandle to draw your own handle. Koasty makes it clickable for you; call state.toggle() if your handle has its own button:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(displayMode = KoastDisplayMode.Stacked()),
stackHandle = { state ->
Text(if (state.expanded) "Collapse" else "+${state.moreCount}")
}
) {
AppContent()
}Use KoastyHostConfig to adapt the default notification to your design system:
KoastyProvider(
koastManager = koastManager,
config = KoastyHostConfig(
containerColor = MaterialTheme.colorScheme.inverseSurface,
contentColor = MaterialTheme.colorScheme.inverseOnSurface,
shape = RoundedCornerShape(16.dp),
shadowElevation = 12.dp,
horizontalSwipeEnabled = true,
swipeUpEnabled = true
)
) {
AppContent()
}For complete visual control, pass koastContent and render the KoastRequest yourself. Koasty still draws the container and handles position, gestures and animations. To add a leading icon while keeping the standard title and message, combine your content with DefaultKoastContent:
val config = KoastyHostConfig()
KoastyProvider(
koastManager = koastManager,
config = config,
koastContent = { koast ->
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(Icons.Rounded.Notifications, contentDescription = null)
Spacer(Modifier.width(12.dp))
DefaultKoastContent(koast = koast, config = config, modifier = Modifier.weight(1f))
}
}
) {
AppContent()
}Pass a KoastStyle to any show* method to override the host config for that koast alone. Every property is optional; null keeps the host value.
koastManager.showSuccess("Saved") // green
koastManager.showError("Upload failed", "Try again later") // red
koastManager.showWarning("Low storage") // amber
koastManager.showInfo("New version available") // blue
koastManager.showToast("Copied to clipboard") // pill at the bottom center, no swipe
koastManager.show("Saved", style = KoastStyle.Success.copy(shape = RoundedCornerShape(24.dp)))A style can also set the position, size, padding around the card, gestures and the content itself. Give your own style a call site with an extension function, the same way the built-in shortcuts work:
private val PromoStyle = KoastStyle(
position = KoastPosition.TOP_END,
compact = true,
containerColor = Color(0xFF6A1B9A),
contentColor = Color.White,
shape = RoundedCornerShape(topStart = 24.dp, bottomEnd = 24.dp),
outerPadding = PaddingValues(16.dp),
)
fun KoastManager.showPromo(title: String) = show(title, duration = 5.seconds, style = PromoStyle)Each position is its own lane, so a toast at the bottom shows right away even while a persistent banner is up at the top. A keyed koast takes the style of its latest call, so showInfo("Uploading…", key = "upload") followed by showSuccess("Uploaded", key = "upload") turns the same koast green. See per-koast styles for every property.
Clone the repository and use the included Gradle wrapper:
# Android
./gradlew :androidApp:assembleDebug
# Desktop
./gradlew :desktopApp:run
# Web (Wasm)
./gradlew :webApp:wasmJsBrowserDevelopmentRun
# Web (JavaScript)
./gradlew :webApp:jsBrowserDevelopmentRunFor iOS, open iosApp/iosApp.xcodeproj in Xcode and run the application from there.
On Windows, replace ./gradlew with gradlew.bat.
./gradlew :koasty:buildNative Apple binaries must be built on macOS.
koasty/ Compose Multiplatform library
shared/ Shared UI for the sample applications
androidApp/ Android sample entry point
desktopApp/ Desktop sample entry point
webApp/ JavaScript and Wasm sample entry points
iosApp/ iOS sample entry point
docs/ Documentation site (Docs7)
Contributions of all sizes are welcome.
master.For larger API or behavior changes, open an issue first so the design can be discussed before implementation.
Koasty is distributed under the Apache License 2.0. See the repository license for details.
Built with 💖 for Kotlin Multiplatform / Compose Multiplatform .