Lazy layouts for Compose HTML.
Add a dependency on the library:
// Configure the project for Kotlin Multiplatform
// Don't forget to add the Compose plugin
kotlin {
js(IR) {
browser()
}
sourceSets.jsMain.dependencies {
implementation("dev.opensavvy.compose.lazy:lazy-layouts:<version>")
}
}To select a version, see the list of releases.
This library introduces lazy layout implementations that work with Compose HTML:
@Composable
fun ShowUsers(users: List<UserId>) {
LazyColumn {
items(users) { userId ->
var user by remember { mutableStateOf<User?>(null) }
LaunchedEffect(userId) {
user = requestUser(userId)
}
user?.also { Show(it) }
}
}
}- Items are loaded batch by batch when the end of the loaded section is reached.
- Items can change size.
- Sections can change over time by editing the backing list, items from other sections are not reloaded.
- The library only adds the most minimal CSS to make the containing
divuse flex, the style is entirely customizable with plain CSS or through the Compose HTMLattrsbuilder.
To learn more, see the documentation.
A full example project is available here. The latest version is deployed here.
This project is licensed under the Apache 2.0 license.
See CONTRIBUTING.md.
- To learn more about our coding conventions and workflow, see the OpenSavvy website.
- This project is based on the OpenSavvy Playground, a collection of preconfigured project templates.
If you don't want to clone this project on your machine, it is also available using GitPod and DevContainer (VS Code • IntelliJ & JetBrains IDEs). Don't hesitate to create issues if you have problems getting the project up and running.