table
look
Typed columns: sort, filter, totals, row select and export; rows on a phone.
Drawn
Invoices5 rows
| Invoice | Client | Status | Due↑ | Overduedays | Amount฿ |
|---|---|---|---|---|---|
| INV-0133 | Orchard Lane Clinic | overdue | 18 Oct 2569 | 32 | 48,750.00 |
| INV-0136 | Bluepeak Logistics | disputed | 5 Nov 2569 | 14 | 31,500.00 |
| INV-0138 | Saffron & Salt | sent | 19 Nov 2569 | 18,000.00 | |
| INV-0139 | Tidewater Bakery | paid | 26 Nov 2569 | 15,000.00 | |
| INV-0143 | Moss Hill School | draft | 13,500.00 | ||
| Total | 126,750.00 |
Mark-up · K-12 tower6 rows
| Item | Qty | Unit cost฿ | Mult | Cost฿ | Margin% | Price฿ | Final฿ |
|---|---|---|---|---|---|---|---|
| Pipework2 | 19,614.00 | 24,069.23 | 24,100.00 | ||||
| Steel pipe 2in, sch 40 | 40 | 410.00 | 1.05 | 17,220.00 | 18 | 21,000.00 | 21,000.00 |
| Elbow 2in 90° | 24 | 95.00 | 1.05 | 2,394.00 | 22 | 3,069.23 | 3,100.00 |
| Valves2 | 29,370.00 | 34,552.94 | 34,600.00 | ||||
| Gate valve 3in | 4 | 4,200.00 | 1.1 | 18,480.00 | 15 | 21,741.18 | 21,800.00 |
| Ball valve 2in | 6 | 1,650.00 | 1.1 | 10,890.00 | 15 | 12,811.76 | 12,800.00 |
| Labour2 | 20,000.00 | 24,800.00 | 24,800.00 | ||||
| Fitter, day | 6 | 2,400.00 | 1 | 14,400.00 | 25 | 19,200.00 | 19,200.00 |
| Transport, by weight | 1 | 5,600.00 | 1 | 5,600.00 | 0 | 5,600.00 | 5,600.00 |
| Total | 68,984.00 | 83,422.17 | 83,500.00 |
OT requests4 rows
| Request | Employee | Status | Hours |
|---|---|---|---|
| OT-2400 | Somchai P. | pending | 2 |
| OT-2399 | Nattaya K. | pending | 3 |
| OT-2398 | Arthit W. | approved | 4 |
| OT-2397 | Wanida T. | rejected | 2 |
| Total | 11 |
The sample
crates/blocks/src/kind/core/table.rs:885–953
fn table() -> Block {
let label = |text: &str, tone: Tone| {
Cell::Label(Label {
text: text.into(),
tone: Some(tone),
})
};
let rows = vec![
invoice(
"INV-0133",
"Orchard Lane Clinic",
label("overdue", Tone::Warn),
Some("2026-10-18"),
Some(32),
48_750,
),
invoice(
"INV-0136",
"Bluepeak Logistics",
label("disputed", Tone::Bad),
Some("2026-11-05"),
Some(14),
31_500,
),
invoice(
"INV-0138",
"Saffron & Salt",
label("sent", Tone::Done),
Some("2026-11-19"),
None,
18_000,
),
invoice(
"INV-0139",
"Tidewater Bakery",
label("paid", Tone::Ok),
Some("2026-11-26"),
None,
15_000,
),
invoice(
"INV-0143",
"Moss Hill School",
label("draft", Tone::Mute),
None,
None,
13_500,
),
];
let bulk = |action: &str, label: &str, bad: Option<bool>| BulkAction {
action: action.into(),
label: label.into(),
bad,
};
let select = TableSelect {
actions: vec![bulk("remind", "send reminder", None), bulk("void", "void", Some(true))],
};
let table = Table::new(columns(), rows)
.id("invoices")
.title("Invoices")
.sort(TableSort {
by: "due".into(),
dir: SortDir::Asc,
})
.empty("No invoices yet.")
.select(select)
.export(vec![ExportFormat::Csv, ExportFormat::Xlsx]);
Block::Table(Box::new(table))
}crates/blocks/src/kind/core/table.rs:794–836
fn grid() -> Block {
let group = |id: &str, name: &str| TableRow {
id: id.into(),
cells: [("name".to_string(), Cell::Text(name.into()))].into(),
group: Some(true),
..TableRow::default()
};
let get = |k: &str| Expr::Get(k.into());
let cost = Expr::Mul(Box::new([Expr::Mul(Box::new([get("qty"), get("price")])), get("mult")]));
let share = Expr::Div(Box::new([get("margin"), Expr::Lit(Lit::Num(100.into()))]));
let keep = Expr::Sub(Box::new([Expr::Lit(Lit::Num(1.into())), share]));
let sell = Expr::Div(Box::new([get("cost"), keep]));
let rows = vec![
group("g-pipe", "Pipework"),
item("p1", "Steel pipe 2in, sch 40", [40.0, 410.0, 1.05, 18.0, 21_000.0]),
item("p2", "Elbow 2in 90°", [24.0, 95.0, 1.05, 22.0, 3_100.0]),
group("g-valve", "Valves"),
item("v1", "Gate valve 3in", [4.0, 4_200.0, 1.1, 15.0, 21_800.0]),
item("v2", "Ball valve 2in", [6.0, 1_650.0, 1.1, 15.0, 12_800.0]),
group("g-lab", "Labour"),
item("l1", "Fitter, day", [6.0, 2_400.0, 1.0, 25.0, 19_200.0]),
TableRow {
fixed: Some(true),
..item("l2", "Transport, by weight", [1.0, 5_600.0, 1.0, 0.0, 5_600.0])
},
];
let gesture = |action: &str, name: &str| Gesture {
action: action.into(),
name: name.into(),
enabled: None,
};
let table = Table::new(markup(), rows)
.id("grid")
.title("Mark-up · K-12 tower")
.calc(
[("cost".to_string(), cost), ("sell".to_string(), sell)]
.into_iter()
.collect::<std::collections::BTreeMap<_, _>>(),
)
.edit(gesture("set-cell", "cell"))
.reorder(gesture("order", "rows"));
Block::Table(Box::new(table))
}crates/blocks/src/kind/core/table.rs:838–883
fn paged() -> Block {
let col = |id: &str, label: &str, kind: ColumnKind| Column {
id: id.into(),
label: label.into(),
kind,
..Column::default()
};
let hours = Column {
total: Some(Total::Sum),
..col("hours", "Hours", ColumnKind::Number)
};
let columns = vec![
col("req", "Request", ColumnKind::Text),
col("who", "Employee", ColumnKind::Text),
col("status", "Status", ColumnKind::Tone),
hours,
];
let row = |id: &str, who: &str, status: &str, tone: Tone, hours: u32| TableRow {
id: id.into(),
cells: BTreeMap::from([
("req".to_string(), Cell::Text(id.into())),
("who".into(), Cell::Text(who.into())),
(
"status".into(),
Cell::Label(Label {
text: status.into(),
tone: Some(tone),
}),
),
("hours".into(), Cell::Number(hours.into())),
]),
..TableRow::default()
};
let rows = vec![
row("OT-2400", "Somchai P.", "pending", Tone::Warn, 2),
row("OT-2399", "Nattaya K.", "pending", Tone::Warn, 3),
row("OT-2398", "Arthit W.", "approved", Tone::Ok, 4),
row("OT-2397", "Wanida T.", "rejected", Tone::Bad, 2),
];
let more = Page {
action: "ot-more".into(),
cursor: "c:2397".into(),
};
let table = Table::new(columns, rows).id("ot").title("OT requests").next(more);
Block::Table(Box::new(table))
}{
"blocks": [
{
"columns": [
{
"id": "inv",
"kind": "text",
"label": "Invoice",
"phone": "meta"
},
{
"id": "client",
"kind": "text",
"label": "Client",
"phone": "title",
"width": 18
},
{
"id": "status",
"kind": "tone",
"label": "Status"
},
{
"era": "be",
"id": "due",
"kind": "date",
"label": "Due"
},
{
"digits": 0,
"id": "late",
"kind": "bar",
"label": "Overdue",
"max": 60,
"tone": "warn",
"unit": "days"
},
{
"currency": "THB",
"id": "amount",
"kind": "money",
"label": "Amount",
"total": "sum"
}
],
"empty": "No invoices yet.",
"export": [
"csv",
"xlsx"
],
"fallback": {
"subtitle": "5 rows · total amount ฿126,750.00",
"title": "Invoices"
},
"id": "invoices",
"rows": [
{
"cells": {
"amount": 48750,
"client": "Orchard Lane Clinic",
"due": "2026-10-18",
"inv": "INV-0133",
"late": 32,
"status": {
"text": "overdue",
"tone": "warn"
}
},
"id": "INV-0133",
"tap": {
"open": "/invoice/INV-0133"
}
},
{
"cells": {
"amount": 31500,
"client": "Bluepeak Logistics",
"due": "2026-11-05",
"inv": "INV-0136",
"late": 14,
"status": {
"text": "disputed",
"tone": "bad"
}
},
"id": "INV-0136",
"tap": {
"open": "/invoice/INV-0136"
}
},
{
"cells": {
"amount": 18000,
"client": "Saffron & Salt",
"due": "2026-11-19",
"inv": "INV-0138",
"status": {
"text": "sent",
"tone": "done"
}
},
"id": "INV-0138",
"tap": {
"open": "/invoice/INV-0138"
}
},
{
"cells": {
"amount": 15000,
"client": "Tidewater Bakery",
"due": "2026-11-26",
"inv": "INV-0139",
"status": {
"text": "paid",
"tone": "ok"
}
},
"id": "INV-0139",
"tap": {
"open": "/invoice/INV-0139"
}
},
{
"cells": {
"amount": 13500,
"client": "Moss Hill School",
"inv": "INV-0143",
"status": {
"text": "draft",
"tone": "mute"
}
},
"id": "INV-0143",
"tap": {
"open": "/invoice/INV-0143"
}
}
],
"select": {
"actions": [
{
"action": "remind",
"label": "send reminder"
},
{
"action": "void",
"bad": true,
"label": "void"
}
]
},
"sort": {
"by": "due",
"dir": "asc"
},
"title": "Invoices",
"type": "table"
},
{
"calc": {
"cost": {
"mul": [
{
"mul": [
{
"get": "qty"
},
{
"get": "price"
}
]
},
{
"get": "mult"
}
]
},
"sell": {
"div": [
{
"get": "cost"
},
{
"sub": [
1,
{
"div": [
{
"get": "margin"
},
100
]
}
]
}
]
}
},
"columns": [
{
"edit": true,
"id": "name",
"kind": "text",
"label": "Item",
"width": 22
},
{
"digits": 0,
"edit": true,
"id": "qty",
"kind": "number",
"label": "Qty"
},
{
"currency": "THB",
"edit": true,
"id": "price",
"kind": "money",
"label": "Unit cost",
"phone": "meta"
},
{
"edit": true,
"id": "mult",
"kind": "number",
"label": "Mult"
},
{
"currency": "THB",
"id": "cost",
"kind": "money",
"label": "Cost",
"total": "sum"
},
{
"digits": 1,
"edit": true,
"id": "margin",
"kind": "number",
"label": "Margin",
"unit": "%"
},
{
"currency": "THB",
"id": "sell",
"kind": "money",
"label": "Price",
"total": "sum"
},
{
"currency": "THB",
"id": "final",
"kind": "money",
"label": "Final",
"total": "sum"
}
],
"edit": {
"action": "set-cell",
"name": "cell"
},
"fallback": {
"subtitle": "6 rows · total cost ฿68,984.00",
"title": "Mark-up · K-12 tower"
},
"id": "grid",
"reorder": {
"action": "order",
"name": "rows"
},
"rows": [
{
"cells": {
"name": "Pipework"
},
"group": true,
"id": "g-pipe"
},
{
"cells": {
"final": 21000,
"margin": 18,
"mult": 1.05,
"name": "Steel pipe 2in, sch 40",
"price": 410,
"qty": 40
},
"id": "p1"
},
{
"cells": {
"final": 3100,
"margin": 22,
"mult": 1.05,
"name": "Elbow 2in 90°",
"price": 95,
"qty": 24
},
"id": "p2"
},
{
"cells": {
"name": "Valves"
},
"group": true,
"id": "g-valve"
},
{
"cells": {
"final": 21800,
"margin": 15,
"mult": 1.1,
"name": "Gate valve 3in",
"price": 4200,
"qty": 4
},
"id": "v1"
},
{
"cells": {
"final": 12800,
"margin": 15,
"mult": 1.1,
"name": "Ball valve 2in",
"price": 1650,
"qty": 6
},
"id": "v2"
},
{
"cells": {
"name": "Labour"
},
"group": true,
"id": "g-lab"
},
{
"cells": {
"final": 19200,
"margin": 25,
"mult": 1,
"name": "Fitter, day",
"price": 2400,
"qty": 6
},
"id": "l1"
},
{
"cells": {
"final": 5600,
"margin": 0,
"mult": 1,
"name": "Transport, by weight",
"price": 5600,
"qty": 1
},
"fixed": true,
"id": "l2"
}
],
"title": "Mark-up · K-12 tower",
"type": "table"
},
{
"columns": [
{
"id": "req",
"kind": "text",
"label": "Request"
},
{
"id": "who",
"kind": "text",
"label": "Employee"
},
{
"id": "status",
"kind": "tone",
"label": "Status"
},
{
"id": "hours",
"kind": "number",
"label": "Hours",
"total": "sum"
}
],
"fallback": {
"subtitle": "4 rows · total hours 11",
"title": "OT requests"
},
"id": "ot",
"more": {
"action": "ot-more",
"cursor": "c:2397"
},
"rows": [
{
"cells": {
"hours": 2,
"req": "OT-2400",
"status": {
"text": "pending",
"tone": "warn"
},
"who": "Somchai P."
},
"id": "OT-2400"
},
{
"cells": {
"hours": 3,
"req": "OT-2399",
"status": {
"text": "pending",
"tone": "warn"
},
"who": "Nattaya K."
},
"id": "OT-2399"
},
{
"cells": {
"hours": 4,
"req": "OT-2398",
"status": {
"text": "approved",
"tone": "ok"
},
"who": "Arthit W."
},
"id": "OT-2398"
},
{
"cells": {
"hours": 2,
"req": "OT-2397",
"status": {
"text": "rejected",
"tone": "bad"
},
"who": "Wanida T."
},
"id": "OT-2397"
}
],
"title": "OT requests",
"type": "table"
}
],
"fallback": {
"title": "screen"
},
"id": "table",
"type": "screen"
}Its fallback
What a renderer without
table draws: a row from the fallback the block carries.Invoices5 rows · total amount ฿126,750.00
Style hooks
.b-tablethe block
[data-block=table]every block of the kind
[data-id=invoices]this one block
Every page here is a blocks
Screen, written by site::page: no hand-written HTML. Source: https://github.com/jirathip-dev/blocks