Search code examples
rreactable

Insert borders underneath selected rows in reactable R


I am trying to put black borders beneath specific rows of a Reactable table in R. For instance, using the cars dataframe as an example, I would like to put a horizantal black line beneath the 2nd and 4th rows of the table generated with the code below:

library(reactable)
reactable(head(cars))

I would like the output to look like the one in the image below:

enter image description here


Solution

  • You can use the rowStyle argument, as in:

    library(reactable)
    reactable(head(cars),
              rowStyle = function(index) {
                if (index %in% c(3, 5)) {
                  list(`border-top` = "thin solid")
                }
              })