andandandand
andandandand

Reputation: 22280

Shiny - Text style for rows of renderTable / renderDataTable

How can I show the text of the first two rows in a renderTable in bold? Can I do this without DT/renderDataTable?

Upvotes: 1

Views: 2569

Answers (2)

conrad-mac
conrad-mac

Reputation: 893

Try this:

library(shiny)

ui <- fluidPage(
    tags$head(
        tags$style(
            "tr:nth-child(1) {font-weight: bold;}
             tr:nth-child(2) {font-weight: bold;}
            "
        )
    ),
    tableOutput("tbl")
)

server <- function(input, output){

    output$tbl <- renderTable({iris})
}

shinyApp(ui, server)

Upvotes: 1

Tonio Liebrand
Tonio Liebrand

Reputation: 17729

How about this:

shinyApp(
  ui = fluidPage(
    tags$head(
      tags$style(
        HTML("tr:first-child, tr:first-child + tr { font-weight: bold }")
      )
    ),
    fluidRow(
      column(12, tableOutput('table')
      )
    )
  ),
  server = function(input, output) {
    output$table <- renderTable(head(iris))
  }
)

Upvotes: 3

Related Questions