Table (reactable)

#| standalone: true
#| components: [viewer]
#| viewerHeight: 200

library(shiny)
library(bslib)
library(reactable)
library(palmerpenguins)

ui <- page_fluid(
  reactableOutput("table") 
)

server <- function(input, output) {
  output$table <- renderReactable({reactable(penguins)}) 
}

shinyApp(ui = ui, server = server)
library(shiny)
library(bslib)
library(reactable)
library(palmerpenguins)

ui <- page_fluid(
  reactableOutput("table") 
)

server <- function(input, output) {
  output$table <- renderReactable({reactable(penguins)}) 
}

shinyApp(ui = ui, server = server)
No matching items

Relevant Functions

  • reactableOutput
    reactableOutput(outputId, width = "auto", height = "auto", inline = FALSE)

  • renderReactable
    renderReactable(expr, env = parent.frame(), quoted = FALSE)

No matching items

Details

To make a reactive interactive table with reactable, follow these steps:

  1. Install (install.packages("reactable")) and load (library(reactable)) the reactable package.

  2. Call reactableOutput() in the UI of your app to create a div in which to display the table. Where you call this function within the UI functions will determine where the gt table will appear within the layout of the app. Set the outputId argument of reactableOutput() to a unique value.

  3. Optionally, use the height, width, and inline arguments of reactableOutput() to control the appearance and positioning of the table.

  4. Within the server function, call renderReactable() and save its output as an element of the output list. Name the element after the outputId used above. For example, output$table <- renderReactable(). reactableOutput() will display the value of the output element whose name matches its outputId.

  5. Pass renderReactable() a block of code, surrounded with {}, that returns a reactable widget. Use reactable()’s arguments to control the appearance and behavior of the table.