An implementation of the Material Design data table for Compose

An implementation of the Material Design data table for Compose

Compose Data Table

This library is an implementation of the Material Design data table for Compose.

The original code is derived from the implementation that was removed from Compose pre-1.0. The goal is to implement the entire Material Design spec for data tables.

Getting started

Add the dependency to your gradle build file:

implementation("com.seanproctor:datatable:0.2.1")

Draw a table

var selectedRow by remember { mutableStateOf<Int?>(null) }
Table(
    columns = listOf(
        TableColumnDefinition {
            Text("Header A")
        },
        TableColumnDefinition {
            Text("Header B")
        },
        TableColumnDefinition(Alignment.CenterEnd) {
            Text("Header C")
        },
    )
) {
    row {
        onClick = { selectedRow = 0 }
        cell { Text("Cell A1") }
        cell { Text("Cell B1") }
        cell { Text("Cell C1") }
    }
    row {
        onClick = { selectedRow = 1 }
        cell { Text("Cell A2") }
        cell { Text("Cell B2") }
        cell { Text("Cell C2") }
    }
}

GitHub

View Github

Leave a Reply

Your email address will not be published. Required fields are marked *