Table example
See original GitHub issueHi,
I mentioned this on Twitter, but I’d really love to see an example of displaying tabular data with Ink.
I’ve figured out how to get tabular columns aligned using flexBasis
/minWidth
, but it’s a hack–I have to find the max string length of all table headers and data in table cells (for each column), then share this number among each cell in the column & the associated header.
e.g. (pseudo-jsx):
<!-- colSizes must be manually computed -->
<Box flexDirection="column">
<Box>
<Box flexBasis={colSize[0]}>HeaderA</Box>
<Box flexBasis={colSize[1]}>HeaderB</Box>
<Box flexBasis={colSize[2]}>HeaderC</Box>
</Box>
<Box>
{rows.map(row => (
<Box flexBasis={colSize[0]}>{row[0]}</Box>
<Box flexBasis={colSize[1]}>{row[1]}</Box>
<Box flexBasis={colSize[2]}>{row[2]}</Box>
))}
</Box>
</Box>
My feeling is that <Box>
is perhaps not well-suited to this task, but could be wrong–I’m inexperienced with both React and flexbox.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
HTML Tables - W3Schools
A table in HTML consists of table cells inside rows and columns. Example. A simple HTML table: <table> <tr>
Read more >HTML table basics - Learn web development | MDN
A table allows you to quickly and easily look up values that indicate some kind of connection between different types of data, for...
Read more >HTML Tables – Table Tutorial with Example Code
A table is a representation of data arranged in rows and columns. Really, it's more like a spreadsheet. In HTML, with the help...
Read more >HTML - Tables - Tutorialspoint
HTML - Tables, The HTML tables allow web authors to arrange data like text, images, links, other tables, etc. into rows and columns...
Read more >Create An HTML Table Quickly & Easily With Our Code ...
Tables : This reference explains all the attributes for use with the TABLE tag, ... What does Create An HTML Table Quickly &...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One thing you could do is split up into columns manually, e.g.
left
,middle
,right
arrays, then render them into separate<Box flexDirection="column">
and wrap that whole thing into a<Box flexDirection="row">
I don’t know if that’s something that should be encouraged, but it works at least 🙂
CSS grid is probably far off: https://github.com/facebook/yoga/issues/867. It would be sweet though 😀