reactable icon indicating copy to clipboard operation
reactable copied to clipboard

Is it possible to create table with vertical header? <th> as a row

Open nabiila-29 opened this issue 3 years ago • 1 comments

Example: image

The idea is to create an information like above without any border

nabiila-29 avatar Jul 10 '23 09:07 nabiila-29

Hi, I think this is technically possible if you hide the column headers with CSS and mark up a column as row headers (to be effectively the same as <th>). But I wouldn't really recommend it with reactable, as pretty much every feature assumes a column-wise table. There won't be any useful pagination, filtering, sorting, etc. So I'd really recommend creating this manually as an HTML table or using a different package.

To hide column headers and mark up a column as row headers, here's a quick example:

reactable(
  MASS::Cars93[, c("Model", "Manufacturer", "Min.Price")],
  columns = list(
    Model = colDef(rowHeader = TRUE, style = list(fontWeight = "bold"))
  ),
  defaultColDef = colDef(headerStyle = list(display = "none")),
  bordered = TRUE
)

glin avatar Jul 25 '23 04:07 glin