Table

fun <T : Any, C> Table(itemsCount: Int, itemAt: (Int) -> T?, state: TableState<C>, columns: ImmutableList<ColumnSpec<T, C, Unit>>, modifier: Modifier = Modifier, placeholderRow: @Composable () -> Unit? = null, emptyContent: @Composable TableEmptyScope.() -> Unit = TableDefaults.EmptyContent, bodyOverlay: @Composable BoxScope.() -> Unit = {}, rowKey: (item: T?, index: Int) -> Any = DefaultRowKey, rowKeyAt: (index: Int) -> Any? = null, onRowClick: (T) -> Unit? = null, onRowLongClick: (T) -> Unit? = null, onRowMove: (fromIndex: Int, toIndex: Int) -> Unit? = null, rowBlocks: RowBlocks<T>? = null, contextMenu: @Composable (item: T, pos: Offset, dismiss: () -> Unit) -> Unit? = null, customization: TableCustomization<T, C> = DefaultTableCustomization(), colors: TableColors = TableDefaults.colors(), typography: TableTypography = TableDefaults.typography(), strings: StringProvider = DefaultStrings, filterChips: TableFilterChipStyle<C> = TableFilterChipDefaults.style(), verticalState: LazyListState = rememberLazyListState(), horizontalState: ScrollState = rememberScrollState(), icons: TableHeaderIcons = TableHeaderDefaults.icons(), columnMenu: ColumnMenuBuilder<C> = ColumnMenuDefaults.builder(), shape: Shape = MaterialTheme.shapes.extraSmall, border: BorderStroke? = null, rowEmbedded: @Composable (rowIndex: Int, item: T) -> Unit? = null, embedded: Boolean = false)

Composable read-only data table that renders a header and a virtualized list of rows.

This is a convenience wrapper around EditableTable for tables without editing support.

  • Columns are described by columns (ColumnSpec).

  • Data is provided via itemsCount and itemAt loader.

  • Sorting, filters, ordering and selection are controlled by state.

Generic parameters:

  • T actual row item type.

  • C column key type.

Parameters

itemsCount

total number of rows to display

itemAt

loader that returns an item for the given index; may return null while loading

state

mutable table state (sorting, filters, order, selection)

columns

list of visible/available column specifications

modifier

layout modifier for the whole table

placeholderRow

optional row content shown when an item is null

emptyContent

body content shown while itemsCount is 0; header, fast filters and footer stay visible. Its TableEmptyScope tells whether filters are active and can clear them. Pass {} for a blank body — also while data is still loading, which an empty count cannot tell apart.

bodyOverlay

content drawn over the visible rows area — below the header, above a pinned footer — that stays in place while the rows scroll in either direction. Align children through BoxScope. The box itself takes no input, so rows under its empty parts stay clickable. Content aligned to the bottom draws over the last rows, or an unpinned footer scrolled into view.

rowKey

stable key for rows; defaults to index

onRowClick

row primary action handler

onRowLongClick

optional long-press handler

contextMenu

optional context menu host, invoked with item and absolute position

customization

styling hooks for rows and cells

colors

container/content colors

typography

text styles of the header, body, footer and group rows

strings

string provider for UI text

filterChips

how the chips of the active filters row are drawn

verticalState

list scroll state

horizontalState

horizontal scroll state of the whole table

icons

header icons used for sort and filter affordances

columnMenu

shapes the column header menu; receives the default sections per column

shape

surface shape of the table

border

outer border stroke; null uses theme default, TableDefaults.NoBorder disables border

embedded

When true, the table renders at its full intrinsic height with no internal vertical scrolling — every row is laid out at once. Use this when embedding the table inside an already-scrollable container (e.g. a row of another table). When false (default), the table occupies a bounded area and scrolls its rows internally.


fun <T : Any, C, E> Table(itemsCount: Int, itemAt: (Int) -> T?, state: TableState<C>, columns: ImmutableList<ColumnSpec<T, C, E>>, tableData: E, modifier: Modifier = Modifier, placeholderRow: @Composable () -> Unit? = null, emptyContent: @Composable TableEmptyScope.() -> Unit = TableDefaults.EmptyContent, bodyOverlay: @Composable BoxScope.() -> Unit = {}, rowKey: (item: T?, index: Int) -> Any = DefaultRowKey, rowKeyAt: (index: Int) -> Any? = null, onRowClick: (T) -> Unit? = null, onRowLongClick: (T) -> Unit? = null, onRowMove: (fromIndex: Int, toIndex: Int) -> Unit? = null, rowBlocks: RowBlocks<T>? = null, contextMenu: @Composable (item: T, pos: Offset, dismiss: () -> Unit) -> Unit? = null, customization: TableCustomization<T, C> = DefaultTableCustomization(), colors: TableColors = TableDefaults.colors(), typography: TableTypography = TableDefaults.typography(), strings: StringProvider = DefaultStrings, filterChips: TableFilterChipStyle<C> = TableFilterChipDefaults.style(), verticalState: LazyListState = rememberLazyListState(), horizontalState: ScrollState = rememberScrollState(), icons: TableHeaderIcons = TableHeaderDefaults.icons(), columnMenu: ColumnMenuBuilder<C> = ColumnMenuDefaults.builder(), shape: Shape = MaterialTheme.shapes.extraSmall, border: BorderStroke? = null, rowEmbedded: @Composable (rowIndex: Int, item: T) -> Unit? = null, embedded: Boolean = false)

Composable data table with custom table data state.

This overload allows passing custom table data that will be accessible in headers, footers, and edit cells.

  • Columns are described by columns (ColumnSpec).

  • Data is provided via itemsCount and itemAt loader.

  • Sorting, filters, ordering and selection are controlled by state.

Generic parameters:

  • T actual row item type.

  • C column key type.

  • E table data type - shared state accessible in headers, footers, and edit cells.

Parameters

itemsCount

total number of rows to display

itemAt

loader that returns an item for the given index; may return null while loading

state

mutable table state (sorting, filters, order, selection)

columns

list of visible/available column specifications

tableData

current table data instance - accessible in headers, footers, and edit cells

modifier

layout modifier for the whole table

placeholderRow

optional row content shown when an item is null

emptyContent

body content shown while itemsCount is 0; header, fast filters and footer stay visible. Its TableEmptyScope tells whether filters are active and can clear them. Pass {} for a blank body — also while data is still loading, which an empty count cannot tell apart.

bodyOverlay

content drawn over the visible rows area — below the header, above a pinned footer — that stays in place while the rows scroll in either direction. Align children through BoxScope. The box itself takes no input, so rows under its empty parts stay clickable. Content aligned to the bottom draws over the last rows, or an unpinned footer scrolled into view.

rowKey

stable key for rows; defaults to index

onRowClick

row primary action handler

onRowLongClick

optional long-press handler

contextMenu

optional context menu host, invoked with item and absolute position

customization

styling hooks for rows and cells

colors

container/content colors

typography

text styles of the header, body, footer and group rows

strings

string provider for UI text

filterChips

how the chips of the active filters row are drawn

verticalState

list scroll state

horizontalState

horizontal scroll state of the whole table

icons

header icons used for sort and filter affordances

columnMenu

shapes the column header menu; receives the default sections per column

shape

surface shape of the table

border

outer border stroke; null uses theme default, TableDefaults.NoBorder disables border

embedded

When true, the table renders at its full intrinsic height with no internal vertical scrolling — every row is laid out at once. Use this when embedding the table inside an already-scrollable container (e.g. a row of another table). When false (default), the table occupies a bounded area and scrolls its rows internally.