Skip to content

About

Compose Multiplatform reactive keyboard-aware layout. Handle keyboard insets on Android & iOS with a single composable.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

cmp-keyboard

JitPack Build Status Platform Kotlin License

Compose Multiplatform reactive keyboard-aware layout engine.

cmp-keyboard before/after comparison


⚡ Why cmp-keyboard?

Compose Multiplatform has historically lacked consistent software keyboard handling across mobile platforms:

  • Android — Modifier.imePadding() behaves inconsistently on foldables, landscape modes, and edge-to-edge gesture navigation.
  • iOS — The software keyboard overlays Compose content entirely by default without automatic insets.

cmp-keyboard solves this with one declarative composable that works seamlessly everywhere.


📦 Installation

Add the JitPack repository and dependency to your build.gradle.kts:

repositories {
    maven { url = uri("https://jitpack.io") }
}

dependencies {
    implementation("com.github.govindtank:cmp-keyboard:1.0.0")
}

🚀 Quick Start

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.*
import androidx.compose.runtime.*
import io.github.govindtank.keyboard.KeyboardAware
import io.github.govindtank.keyboard.rememberKeyboardInfo

@Composable
fun ChatScreen() {
    val keyboard by rememberKeyboardInfo()
    var text by remember { mutableStateOf("") }

    KeyboardAware {
        Column {
            LazyColumn(modifier = Modifier.weight(1f)) {
                // message list
            }
            TextField(value = text, onValueChange = { text = it })
            Button(onClick = { /* send */ }) { 
                Text("Send") 
            }
        }
    }

    if (keyboard.isVisible) {
        Text("Keyboard Height: ${keyboard.height}")
    }
}

📱 Platform Support

Platform Detection Mechanism Notes
Android ViewTreeObserver.OnGlobalLayoutListener Works on foldables, landscape, edge-to-edge
iOS UIResponder.keyboardWillShowNotification / keyboardWillHideNotification Uses safe-area insets (iOS 15+)

💖 Support the Project

If you find this project useful, consider supporting its active maintenance and future development:

Buy Me A Coffee GitHub Sponsors Patreon


📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Maintained with ❤️ by Govind Tank.

About

Compose Multiplatform reactive keyboard-aware layout. Handle keyboard insets on Android & iOS with a single composable.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages