
A simple, customizable, and modern library for displaying alert banners in your Jetpack Compose and Compose Multiplatform applications. Easily integrate and adapt to suit any style or use case - from error notifications to informational messages!
A simple, customizable, and modern library for displaying alert banners in your Jetpack Compose, Compose Multiplatform, and native iOS (Swift) applications. Easily integrate and adapt to suit any style or use case—from error notifications to informational messages!
Compose Alert Banner is a Kotlin library powered by Compose Multiplatform, dedicated to providing developers an easy and elegant way to add alert banners to their applications. This library comes with a robust set of features, allowing your alert banners to be as simple or as sophisticated as needed.
Whether you need to show warnings, confirmations, or general notifications, Compose Alert Banner provides an intuitive API and customizable components that blend seamlessly with your app’s UI.
Here's how it looks:
| Android | iOS | Desktop | |
|---|---|---|---|
![]() |
![]() |
![]() |
|
Compose Alert Banner is available as a Gradle dependency on mavenCentral. You can add it to your project by including the following in your build.gradle.kts file:
repositories {
mavenCentral()
}
dependencies {
implementation("com.mofeejegi.alert:alert-banner-compose:<latest-version>")
}Replace <latest-version> with the current release version available in the Releases section.
Integrating the alert banner into your Compose application is straightforward. Below is a simple example to get you started:
@Composable
fun MyApp() {
MaterialTheme {
AlertBanner(darkTheme = false) { // Declare this at the root of your application
// This is accessible at any part of your application
val alertManager = rememberAlertManager()
Column(modifier = Modifier.fillMaxSize()) {
Button(onClick = { alertManager.show("Error", AlertBannerType.Error) }) {
Text("Show Error Alert")
}
Button(onClick = { alertManager.show("Success", AlertBannerType.Success) }) {
Text("Show Success Alert")
}
// Custom takes its own colors; showIcon = false hides its icon
Button(onClick = {
alertManager.show("Custom", AlertBannerType.Custom(containerColor = Color(0xFF_6750A4), contentColor = Color.White))
}) {
Text("Show Custom Alert")
}
}
}
}
}Compose Alert Banner can be used directly in native Swift iOS projects via Swift Package Manager — no Compose or Kotlin knowledge required.
In Xcode, go to File > Add Package Dependencies and enter:
https://github.com/mofeejegi/compose-alert-banner
Select the latest version from the Releases page. Requires iOS 14 or later.
Call attach() once at the root of your app. Then call showSuccess or showError from anywhere. The overlay only catches touches on the banners themselves; everything else reaches your app as usual.
attach() uses your app's active window scene. If your app supports multiple windows, use attach(scene:) to choose the scene the banners appear in.
import AlertBanner
@main
struct MyApp: App {
let alertBanner = AlertBannerIOS.shared
var body: some Scene {
WindowGroup {
ContentView()
.onAppear { alertBanner.attach() }
}
}
}
struct ContentView: View {
let alertBanner = AlertBannerIOS.shared
var body: some View {
VStack {
Button("Show Success") {
alertBanner.showSuccess(message: "Saved successfully!")
}
Button("Show Error") {
alertBanner.showError(message: "Something went wrong")
}
}
}
}Call install(on:) once on your root view controller. Then call showSuccess or showError from anywhere.
import AlertBanner
class RootViewController: UIViewController {
let alertBanner = AlertBannerIOS.shared
override func viewDidLoad() {
super.viewDidLoad()
alertBanner.install(on: self)
}
@objc func onSave() {
alertBanner.showSuccess(message: "Saved successfully!")
}
@objc func onError() {
alertBanner.showError(message: "Something went wrong")
}
}| Method | Description |
|---|---|
AlertBannerIOS.shared |
Singleton instance - use from anywhere |
.attach() |
Creates a window overlay in the active scene. Call once at the root |
.attach(scene:) |
Creates the overlay in the given UIWindowScene, or moves it there if already attached |
.install(on:) |
Adds as a child view controller. Call once on the root view controller |
.showSuccess(message:) |
Shows a success alert banner |
.showError(message:) |
Shows an error alert banner |
.configure(darkTheme:) |
Sets dark/light theme. Call before attach() or install(on:). Defaults to system appearance |
.detach() |
Removes the overlay window |
.uninstall() |
Removes the child view controller |
Compose Alert Banner offers multiple configuration options:
Contributions, issues, and feature requests are welcome! Please:
git checkout -b feature/YourFeature).git commit -am 'Add new feature').git push origin feature/YourFeature).Be sure to follow the existing code style and include tests where applicable.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
For questions or suggestions, open an issue or reach out directly:
A simple, customizable, and modern library for displaying alert banners in your Jetpack Compose, Compose Multiplatform, and native iOS (Swift) applications. Easily integrate and adapt to suit any style or use case—from error notifications to informational messages!
Compose Alert Banner is a Kotlin library powered by Compose Multiplatform, dedicated to providing developers an easy and elegant way to add alert banners to their applications. This library comes with a robust set of features, allowing your alert banners to be as simple or as sophisticated as needed.
Whether you need to show warnings, confirmations, or general notifications, Compose Alert Banner provides an intuitive API and customizable components that blend seamlessly with your app’s UI.
Here's how it looks:
| Android | iOS | Desktop | |
|---|---|---|---|
![]() |
![]() |
![]() |
|
Compose Alert Banner is available as a Gradle dependency on mavenCentral. You can add it to your project by including the following in your build.gradle.kts file:
repositories {
mavenCentral()
}
dependencies {
implementation("com.mofeejegi.alert:alert-banner-compose:<latest-version>")
}Replace <latest-version> with the current release version available in the Releases section.
Integrating the alert banner into your Compose application is straightforward. Below is a simple example to get you started:
@Composable
fun MyApp() {
MaterialTheme {
AlertBanner(darkTheme = false) { // Declare this at the root of your application
// This is accessible at any part of your application
val alertManager = rememberAlertManager()
Column(modifier = Modifier.fillMaxSize()) {
Button(onClick = { alertManager.show("Error", AlertBannerType.Error) }) {
Text("Show Error Alert")
}
Button(onClick = { alertManager.show("Success", AlertBannerType.Success) }) {
Text("Show Success Alert")
}
// Custom takes its own colors; showIcon = false hides its icon
Button(onClick = {
alertManager.show("Custom", AlertBannerType.Custom(containerColor = Color(0xFF_6750A4), contentColor = Color.White))
}) {
Text("Show Custom Alert")
}
}
}
}
}Compose Alert Banner can be used directly in native Swift iOS projects via Swift Package Manager — no Compose or Kotlin knowledge required.
In Xcode, go to File > Add Package Dependencies and enter:
https://github.com/mofeejegi/compose-alert-banner
Select the latest version from the Releases page. Requires iOS 14 or later.
Call attach() once at the root of your app. Then call showSuccess or showError from anywhere. The overlay only catches touches on the banners themselves; everything else reaches your app as usual.
attach() uses your app's active window scene. If your app supports multiple windows, use attach(scene:) to choose the scene the banners appear in.
import AlertBanner
@main
struct MyApp: App {
let alertBanner = AlertBannerIOS.shared
var body: some Scene {
WindowGroup {
ContentView()
.onAppear { alertBanner.attach() }
}
}
}
struct ContentView: View {
let alertBanner = AlertBannerIOS.shared
var body: some View {
VStack {
Button("Show Success") {
alertBanner.showSuccess(message: "Saved successfully!")
}
Button("Show Error") {
alertBanner.showError(message: "Something went wrong")
}
}
}
}Call install(on:) once on your root view controller. Then call showSuccess or showError from anywhere.
import AlertBanner
class RootViewController: UIViewController {
let alertBanner = AlertBannerIOS.shared
override func viewDidLoad() {
super.viewDidLoad()
alertBanner.install(on: self)
}
@objc func onSave() {
alertBanner.showSuccess(message: "Saved successfully!")
}
@objc func onError() {
alertBanner.showError(message: "Something went wrong")
}
}| Method | Description |
|---|---|
AlertBannerIOS.shared |
Singleton instance - use from anywhere |
.attach() |
Creates a window overlay in the active scene. Call once at the root |
.attach(scene:) |
Creates the overlay in the given UIWindowScene, or moves it there if already attached |
.install(on:) |
Adds as a child view controller. Call once on the root view controller |
.showSuccess(message:) |
Shows a success alert banner |
.showError(message:) |
Shows an error alert banner |
.configure(darkTheme:) |
Sets dark/light theme. Call before attach() or install(on:). Defaults to system appearance |
.detach() |
Removes the overlay window |
.uninstall() |
Removes the child view controller |
Compose Alert Banner offers multiple configuration options:
Contributions, issues, and feature requests are welcome! Please:
git checkout -b feature/YourFeature).git commit -am 'Add new feature').git push origin feature/YourFeature).Be sure to follow the existing code style and include tests where applicable.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
For questions or suggestions, open an issue or reach out directly: