-
Notifications
You must be signed in to change notification settings - Fork 2
toast SETUP
github-actions[bot] edited this page Jun 2, 2026
·
1 revision
io.github.mobilebytelabs:kmp-toast:2.1.0
No Supabase, no DI module, no config class. 3 steps.
[versions]
kmp-toast = "2.1.0"
[libraries]
kmp-toast = { module = "io.github.mobilebytelabs:kmp-toast", version.ref = "kmp-toast" }commonMain.dependencies {
implementation(libs.kmp.toast)
}Place ToastHost at the root level so it renders on top of all screens:
import com.mobilebytelabs.kmptoolkit.toast.ToastHost
import com.mobilebytelabs.kmptoolkit.toast.rememberToastHostState
@Composable
fun App() {
val toastState = rememberToastHostState()
Scaffold { paddingValues ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
) {
NavHost(...) // or your main content
ToastHost(hostState = toastState)
}
}
}@Composable
fun App() {
val toastState = rememberToastHostState()
Box(modifier = Modifier.fillMaxSize()) {
MainContent()
ToastHost(hostState = toastState)
}
}Pass toastState down through your composable tree or inject via a shared ViewModel.
// In ViewModel or event handler — needs CoroutineScope
scope.launch {
toastState.showToast("Copied to clipboard")
}scope.launch {
val result = toastState.showToast(
message = "Message deleted",
actionLabel = "Undo",
duration = ToastDuration.LONG,
)
if (result == ToastResult.ACTION_PERFORMED) {
undoDelete()
}
}scope.launch {
toastState.showToast(
message = "Upload failed",
style = ToastStyle.ERROR,
position = ToastPosition.TOP,
duration = ToastDuration.LONG,
)
}ToastHost(
hostState = toastState,
toast = { data ->
// Your custom toast UI
MyCustomToast(data)
}
)Expose ToastHostState from your ViewModel so screens don't need the state directly:
class AppViewModel : ViewModel() {
val toastState = ToastHostState()
fun showError(message: String) {
viewModelScope.launch {
toastState.showToast(message, style = ToastStyle.ERROR)
}
}
}
// In composable:
val viewModel: AppViewModel = koinViewModel()
ToastHost(hostState = viewModel.toastState)/sync-toast # Verify Gradle + ToastHost placement
/sync-toast --check # Dry run
See CLAUDE_AI_SETUP.md for full docs.
** Partials**
App Intents
Bubble
Clipboard
Cookbook
- Clipboard Copy Text
- Clipboard Read Text
- Consumer Anon Key Setup
- Crashlytics Attribution Per Library
- Ifonline Block
- Index
- Index
- Index
- Index
- Open Url Compose
- Pick And Share Image
- React To Offline
- Register Firebase Hooks
- Share Pdf Android
- Share Text
- Wifi Vs Cellular
Firebase Analytics
In App Update
Intent Launcher
Inter App Comms
Modules
- Cmp App Intents
- Cmp App Intents Compose
- Cmp Bubble
- Cmp Clipboard
- Cmp Deep Link
- Cmp Firebase Analytics
- Cmp In App Update
- Cmp Intent Launcher
- Cmp Intent Launcher Compose
- Cmp Library
- Cmp Network Monitor
- Cmp Network Monitor Compose
- Cmp Observe
- Cmp Observe Koin
- Cmp Open Url
- Cmp Pdf Generator
- Cmp Product Tickets
- Cmp Remote Config
- Cmp Share
- Cmp Share Compose
- Cmp Toast
Network Monitor
Open Url
Pdf Generator
Remote Config
Share
Toast
User Tickets
General