Skip to content

A multiplatform Jetpack Compose library that provides a `@Composable` table with automatic layouts.

License

Notifications You must be signed in to change notification settings

sunny-chung/composable-table

Repository files navigation

Composable Table

Maven Central

A multiplaform Jetpack Compose library that provides a @Composable table with automatic layouts.

Demo Video

Features

  • 2-dimension scrolling
  • Automatic cell width and height calculation using the largest one
  • Maximum cell width/height could be optionally specified
  • Allowing custom composable and action listeners (e.g. clickable) for each cell
  • Infinite table width and height
  • Sticky rows and columns
  • Straight-forward to use

What is NOT included

  • Lazy cells
  • Grid lines (have to be implemented by users themselves inside cells)

Supported Platforms

  • Android
  • Desktop (JVM - Windows/MacOS/Linux)
  • iOS
  • WASM (JS)

Setup

For multiplatform:

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("io.github.sunny-chung:composable-table:<version>")
            
            // ...

For single platform:

    dependencies {
        // ...
        implementation("io.github.sunny-chung:composable-table:<version>")
    }

Usage

Below shows an example of minimal usage.

    Table(
        rowCount = 100,
        columnCount = 10
    ) { rowIndex, columnIndex ->
        Text("($rowIndex, $columnIndex)")
    }

Please read the demo app for a practical usage example. There is a demo app for each platform.

Migration notes

Since v1.2.0, Composable Table moves to Maven Central to provide multiplatform support. Dependency identifier is changed from com.github.sunny-chung:composable-table to io.github.sunny-chung:composable-table.

Users using old version can stay at v1.1.0 because no other change is introduced. You can upgrade to v1.2.0 by changing the dependency identifier and version name to enjoy multiplatform support.

Troubleshooting

If maxCellWidthDp or maxCellHeightDp is specified, please do not use fillMaxXXX modifiers in the root composable of cells, or the cell would occupy maximum size unconditionally. This behaviour is documented in the fillMaxXXX methods of the Compose Foundation library.

Contribution

Contributions are welcomed!

Please also raise an issue if you think a must-have feature is missing!