Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sproctor/compose-data-table

An implementation of the Material Design data table for Compose.
https://github.com/sproctor/compose-data-table

compose compose-multiplatform data-table kotlin-multiplatform

Last synced: about 11 hours ago
JSON representation

An implementation of the Material Design data table for Compose.

Awesome Lists containing this project

README

        

![Maven Central](https://img.shields.io/maven-central/v/com.seanproctor/data-table)

# Compose Data Table

This library is an implementation of the [Material Design data table](https://m2.material.io/components/data-tables) 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.

![screenshot](screenshot.png)

## Getting started

Add the dependency to your gradle build file:

Non-material version:

```kotlin
implementation("com.seanproctor:data-table:")
```

Material 3:

```kotlin
implementation("com.seanproctor:data-table-material3:")
```

Draw a table

```kotlin
var selectedRow by remember { mutableStateOf(null) }
DataTable(
columns = listOf(
DataColumn {
Text("Header A")
},
DataColumn {
Text("Header B")
},
DataColumn(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") }
}
}
```

Draw a paginated table
```kotlin
PaginatedDataTable(
columns = listOf(
DataColumn {
Text("Column1")
},
DataColumn {
Text("Column2")
},
DataColumn {
Text("Column3")
},
),
state = rememberPaginatedDataTableState(5),
) {
for (rowIndex in 0 until 100) {
row {
onClick = { println("Row clicked: $rowIndex") }
cell {
Text("Row $rowIndex, column 1")
}
cell {
Text("Row $rowIndex, column 2")
}
cell {
Text("Row $rowIndex, column 3")
}
}
}
}
```