narteaga
narteaga

Reputation: 147

how can i reduce the height of the rows in tableOutput Shiny?

i want to reduce the height in the rows of a table building with tableOutput i tried with the next code, but not works

in UI.R:

 tableOutput("table"),tag$tr(tags$style(type="text/css", "#table {line-height:50%}"))

but not works, also i tried in server.R

 output$table<- renderTable({
 print(data())
 },include.rownames=F,html.table.attributes=list(cellspacing="10px"))

but not works

Thanks

Upvotes: 2

Views: 2770

Answers (1)

Xin Yin
Xin Yin

Reputation: 2936

A few things:

  • Although you named your data table table in ui.R, it is actually the id of its container (a <div> element), not the <table> itself.
  • Shiny set the line-height attribute at <td> level, so in order to override that, you have to set line-height at <td> level as well.

Below is a working one:

tags$head(tags$style(type="text/css", "#table table td {line-height:50%;}"))

You can use this to replace your tags$tr(...) part.

Upvotes: 2

Related Questions