Skip to content

Table ​

Data table with footnote-weight headings over subhead body rows separated by hairlines. Use it for small, read-only tabular data; numeric columns right-align with tabular figures. Each cell value is looked up in the row map by its column key, and columns share width equally.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismTable
import io.github.heartcoolman.prism.ui.PrismTableColumn

Basic usage ​

kotlin
PrismTable(
    columns = listOf(
        PrismTableColumn(key = "name", header = "Name"),
        PrismTableColumn(key = "qty", header = "Qty", numeric = true),
    ),
    rows = listOf(
        mapOf("name" to "Apples", "qty" to "12"),
        mapOf("name" to "Pears", "qty" to "7"),
    ),
    caption = "Inventory",
)

Columns ​

numeric right-aligns a column and renders its cells with tabular figures (tnum). Override alignment explicitly with align; an unset align falls back to right for numeric columns and left otherwise.

kotlin
PrismTable(
    columns = listOf(
        PrismTableColumn(key = "city", header = "City"),
        PrismTableColumn(key = "code", header = "Code", align = PrismCellAlign.Right),
        PrismTableColumn(key = "pop", header = "Population", numeric = true),
    ),
    rows = listOf(
        mapOf("city" to "Tokyo", "code" to "JP", "pop" to "13960000"),
        mapOf("city" to "Paris", "code" to "FR", "pop" to "2161000"),
    ),
)

API ​

PrismTable ​

ParameterTypeDefaultDescription
columnsList<PrismTableColumn>—Column definitions, in display order.
rowsList<Map<String, String>>—Row data; each cell is looked up by its column key.
modifierModifierModifierModifier applied to the root column.
captionString?nullOptional footnote caption rendered above the table.

PrismTableColumn ​

ParameterTypeDefaultDescription
keyString—Row-map key used to look up the cell value.
headerString—Column heading text.
alignPrismCellAlign?nullText alignment; defaults to right when numeric, else left.
numericBooleanfalseRight-aligns cells and uses tabular figures.

PrismCellAlign ​

ValueDescription
LeftStart-aligned cells.
RightEnd-aligned cells.

Released under the MIT License.