{#- chirp-ui: Table component Responsive table with header configuration and row helper. Usage: from "chirpui/table.html" import table, row Slot-based (complex rows): call table(headers=["Name", "Email", "Role"]) row("Alice", "alice@example.com", "Admin") row("Bob", "bob@example.com", "User") end Data-driven (alignment flows to all cells automatically): table(headers=["Name", "Status", "Count"], rows=[("Alice", "Active", "42"), ("Bob", "Idle", "7")], align=["left", "center", "right"]) Per-column alignment (slot-based, auto-inherited): call table(headers=["Name", "Status", "Count"], align=["left", "center", "right"]) row("Alice", "Active", "42") end Column widths (CSS values or proportions): call table(headers=["Name", "Status"], widths=["2fr", "1fr"]) Slots: caption (table caption), row_actions (header cell for actions column). Sortable headers: call table(headers=["Name", "Email"], sortable=true, sort_url="/users", hx_target="#user-table") row(user.name, user.email) end Row with actions: pass row_actions(...) as last cell when actions_header=true Sticky header: call table(headers=[...], sticky_header=true) Sorting note (legacy): table(sortable=true, sort_url=...) emits a plain `hx-get`-on-`
| {% end %} {% for header in headers %} {% set col_align = align[loop.index0] if align and loop.index0 < align | length else "" %} | {{ header }} | {% end %} {% if actions_header %}{% end %} |
|---|---|---|
| {% end %} {% for cell in row_data %} {% set col_align = align[loop.index0] if align and loop.index0 < align | length else "" %} | {{ cell }} | {% end %}