Tables
Render HTML tables with Takumi, set column widths, and understand differences from browser table layout.
Takumi lays out display: table as a grid, so every row shares one set of column tracks. Column widths follow Blink's table width algorithm, approximately.
< ={{ : "100%" }}>
<>
< ={{ : "#e2e8f0" }}>
<>Name</>
< ={{ : "80px" }}>Qty</>
</>
</>
<>
<>
<>Wireframe kit</>
<>3</>
</>
</>
</>What works
<table>,<thead>,<tbody>,<tfoot>,<tr>,<td>,<th>, and<caption>have element presets in HTML and JSX.- Header groups render first and footer groups last, whatever the source order.
colspanandrowspanspan tracks. The HTML attributes and the JSXcolSpanandrowSpanprops both work.captionrenders above the table, or below it withcaption-side: bottom.- A row's background is copied to cells without their own, so zebra stripes and header bands work. The
border-spacinggaps stay unpainted. - A block-level table with
width: autoshrinks to fit its content. In a flex or grid container, it stretches. - Columns share the table's width by their content. Percentage and fixed cell widths constrain their columns.
border-collapse: collapsemerges adjacent borders.border-spacingdefaults to2px.vertical-alignplaces cell content as Chrome does.baselinecells line up their first lines across a row.- Paged PDF output splits rows across pages. Columns keep the same positions on every page.
Cells keep their box. Padding, borders, and backgrounds cover the cell's full grid area, including rows spanned by rowspan.
Where it drifts
| Behavior | In a browser | In Takumi |
|---|---|---|
<col>, <colgroup> | Their widths size columns | Ignored. Set the width on a cell instead. |
| Caption width | A wide caption widens the table | The caption wraps to the table's width |
Upstream table layout
Takumi lays out flex and grid with Taffy, which has no table algorithm yet. DioxusLabs/taffy#1094 proposes one. Takumi uses the grid-based approach above.
Last updated on