Package-level declarations

Types

Link copied to clipboard
@Immutable
data class CellEdit<T>(val item: T, val rowKey: Any, val columnKey: String, val oldText: String, val newText: String)

A committed cell edit, handed to DataTable's onCellEdit.

Link copied to clipboard
@Stable
class CellEditController

Handle given to a column's DataTableHeader.editorContent, for editors that are not plain text.

Link copied to clipboard
@Immutable
data class CellPosition(val rowKey: Any, val columnKey: String)

Identifies a single cell — the intersection of a row and a column.

Link copied to clipboard
@Immutable
data class CellRange(val anchor: CellPosition, val focus: CellPosition)

A selected block of cells, from the anchor corner to the cursor.

Link copied to clipboard
@Immutable
data class ClipboardSelection<T>(val rows: List<T>, val columns: List<DataTableHeader<T>>, val cells: List<List<String>>)

What a copy covers: the rows, the columns, and the text of every cell where they cross.

Link copied to clipboard

Handle given to a column's DataTableHeader.filterContent, for filters that are not a plain text field.

Link copied to clipboard
@Immutable
data class DataTableColors(val container: Color = Color(0xFFFAFAFA), val header: Color = Color(0xFFF0F0F0), val divider: Color = Color(0xFFDDDDDD), val selectedRow: Color = Color(0x4D1976D2), val expandedRow: Color = Color(0x80F0F0F0), val onSurface: Color = Color(0xFF1C1C1C), val onSurfaceSecondary: Color = Color(0xFF757575), val checkboxChecked: Color = Color(0xFF1976D2), val checkboxUnchecked: Color = Color(0xFF757575), val checkboxCheckmark: Color = Color.White, val iconTint: Color = Color(0xFF616161), val disabledContent: Color = Color(0xFFBDBDBD), val rowAlternate: Color = Color.Transparent, val hoveredRow: Color = Color(0x1A000000), val focusedRowBorder: Color = Color(0xFF1976D2), val focusedCellBorder: Color = Color(0xFF1976D2), val editingCell: Color = Color(0xFFFFFFFF), val invalidCellBorder: Color = Color(0xFFD32F2F), val selectedCell: Color = Color(0x331976D2), val draggedColumn: Color = Color(0x1F1976D2), val columnDropIndicator: Color = Color(0xFF1976D2), val filterRow: Color = Color(0xFFF7F7F7), val filterField: Color = Color(0xFFFFFFFF))

Colors used throughout the DataTable.

Link copied to clipboard

Factory functions for DataTableColors and DataTableTextStyles.

Link copied to clipboard

Density presets that control vertical and horizontal padding for rows and headers.

Link copied to clipboard

Ready-made editors for DataTableHeader.editorContent and the matching cell renderers, for the columns that do not want a free-text field.

Link copied to clipboard

Ready-made formatters for DataTableHeader.format — money, plain numbers, percentages, dates, and booleans.

Link copied to clipboard
@Immutable
data class DataTableHeader<T>(val key: String, val title: String = "", val value: (T) -> Any?? = null, val sortable: Boolean = true, val width: Dp? = null, val align: TextAlign = TextAlign.Start, val fixed: Boolean = false, val visible: Boolean = true, val maxLines: Int = Int.MAX_VALUE, val overflow: TextOverflow = TextOverflow.Clip, val comparator: <Error class: unknown class><T>? = null, val children: List<DataTableHeader<T>>? = null, val headerContent: @Composable () -> Unit? = null, val cellContent: @Composable (T) -> Unit? = null, val editable: Boolean = false, val editValue: (T) -> String? = null, val validateEdit: (T, String) -> String?? = null, val editorContent: @Composable (T, CellEditController) -> Unit? = null, val format: (Any?) -> String? = null, val filterable: Boolean = false, val filterPlaceholder: String = "", val filterPredicate: (T, String) -> Boolean? = null, val filterContent: @Composable (ColumnFilterController) -> Unit? = null, val editOnClick: Boolean = false)

Describes a column in the DataTable.

Link copied to clipboard
@Immutable
data class DataTableLayout(val columnWidths: Map<String, Dp> = emptyMap(), val hiddenColumns: Set<String> = emptySet(), val columnOrder: List<String> = emptyList(), val sortBy: SortState = SortState(), val multiSortBy: List<SortState> = emptyList(), val filters: Map<String, String> = emptyMap())

A snapshot of how a user has arranged a table: column widths, which columns they hid, the order they put them in, the sort they left it under, and the filters they typed.

Link copied to clipboard
@Stable
class DataTableState(lazyListState: LazyListState, horizontalScrollState: ScrollState)

State holder for DataTable.

Link copied to clipboard
@Immutable
data class DataTableTextStyles(val headerCell: TextStyle = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Bold, color = Color(0xFF1C1C1C), ), val bodyCell: TextStyle = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ), val footer: TextStyle = TextStyle( fontSize = 12.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ), val loading: TextStyle = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ), val noData: TextStyle = TextStyle( fontSize = 16.sp, fontWeight = FontWeight.Normal, color = Color(0x991C1C1C), ), val pagination: TextStyle = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ), val cellEditor: TextStyle = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ), val filterField: TextStyle = TextStyle( fontSize = 13.sp, fontWeight = FontWeight.Normal, color = Color(0xFF1C1C1C), ))

Text styles used throughout the DataTable.

Link copied to clipboard

Controls how row selection behaves.

Link copied to clipboard

Represents the sort order applied to a column.

Link copied to clipboard
@Immutable
data class SortState(val key: String = "", val order: SortOrder = SortOrder.NONE)

Current sort configuration for a single column.

Functions

Link copied to clipboard

Puts text on the system clipboard, reporting whether it got there.

Link copied to clipboard

Puts this selection on the system clipboard as tab-separated text, reporting whether it got there.

Link copied to clipboard
@Composable
fun <T> DataTable(items: List<T>, headers: List<DataTableHeader<T>>, itemKey: (T) -> Any, modifier: Modifier = Modifier, state: DataTableState = rememberDataTableState(), showSelect: Boolean = false, selectionMode: SelectionMode = if (showSelect) SelectionMode.MULTI else SelectionMode.NONE, selectedKeys: Set<Any> = emptySet(), onSelectionChange: (Set<Any>) -> Unit? = null, showExpand: Boolean = false, expandedKeys: Set<Any> = emptySet(), onExpandChange: (Set<Any>) -> Unit? = null, expandContent: @Composable (T) -> Unit? = null, density: DataTableDensity = DataTableDensity.DEFAULT, colors: DataTableColors = DataTableDefaults.colors(), textStyles: DataTableTextStyles = DataTableDefaults.textStyles(), sortBy: SortState = SortState(), onSortChange: (SortState) -> Unit? = null, multiSortBy: List<SortState> = emptyList(), onMultiSortChange: (List<SortState>) -> Unit? = null, manualSorting: Boolean = false, filters: Map<String, String> = emptyMap(), onFiltersChange: (Map<String, String>) -> Unit? = null, manualFiltering: Boolean = false, resizableColumns: Boolean = false, minColumnWidth: Dp = 40.dp, reorderableColumns: Boolean = false, rowHeight: Dp? = DataTableDefaults.rowHeight(density), hideDefaultHeader: Boolean = false, hideDefaultFooter: Boolean = false, loading: Boolean = false, loadingContent: @Composable () -> Unit? = null, headerContent: @Composable () -> Unit? = null, footerContent: @Composable () -> Unit? = null, noDataContent: @Composable () -> Unit? = null, noResultsContent: @Composable () -> Unit? = null, showColumnMenuButton: Boolean = false, groupBy: (T) -> String? = null, groupHeaderContent: @Composable (String, List<T>) -> Unit? = null, groupSummaryContent: @Composable (String, List<T>) -> Unit? = null, onRowClick: (T) -> Unit? = null, onRowDoubleClick: (T) -> Unit? = null, onRowContextMenu: (T, Offset) -> Unit? = null, showPagination: Boolean = false, itemsPerPage: Int = 10, currentPage: Int = 0, onPageChange: (Int) -> Unit? = null, itemsPerPageOptions: List<Int> = listOf(10, 25, 50, 100), onItemsPerPageChange: (Int) -> Unit? = null, manualPagination: Boolean = false, totalItems: Int? = null, cellNavigation: Boolean = false, onCellEdit: (CellEdit<T>) -> Unit? = null, onEditStart: (CellPosition) -> Unit? = null, onEditCancel: (CellPosition) -> Unit? = null, onCopy: (ClipboardSelection<T>) -> Unit? = null, showScrollbars: Boolean = true)

A flexible, Compose Multiplatform data table built entirely on Foundation APIs.

Link copied to clipboard
@Composable
fun rememberDataTableState(initialFirstVisibleItemIndex: Int = 0, initialFirstVisibleItemScrollOffset: Int = 0): DataTableState

Creates and remembers a DataTableState.