Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The add_title() function does not work in shiny. #40

Open
akins11 opened this issue Sep 9, 2022 · 1 comment
Open

The add_title() function does not work in shiny. #40

akins11 opened this issue Sep 9, 2022 · 1 comment

Comments

@akins11
Copy link

akins11 commented Sep 9, 2022

Thank you for this wonderful package. When using the add_title() function in shiny, no title is displayed. see:

library(shiny)
library(reactable)
library(reactablefmtr)

ui <- fluidPage(
  reactableOutput(outputId = "table")
)

server <- function(input, output, session) {
  output$table <- renderReactable({
    reactable(data = mtcars) |>
      add_title(title = "Motor Trend Car Table")
  })
}
shinyApp(ui, server)

table_with_no_title

Using the function without shiny:

reactable(data = mtcars) |>
  add_title(title = "Motor Trend Car Table")

table_with_title

R.version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 2.1
year 2022
month 06
day 23
svn rev 82513
language R
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname Funny-Looking Kid

> packageVersion("reactable")
[1] ‘0.3.0> packageVersion("reactablefmtr")
[1] ‘2.0.0> packageVersion("shiny")
[1] ‘1.7.2
@kcuilla
Copy link
Owner

kcuilla commented Oct 14, 2022

Hi, thanks for using reactablefmtr. Unfortunately, the title, subtitle, and source aren't compatible with Shiny because their properties get masked by the Shiny HTML. I'll be sure to add this to the documentation so that users know ahead of time.

A work-around I'd recommend is adding the title above the table within the ui section of the Shiny app like below:

library(shiny)
library(reactable)
library(reactablefmtr)

ui <- fluidPage(
  h2("Motor Trend Car Table"), # add title above table
  reactableOutput(outputId = "table")
)

server <- function(input, output, session) {
  
  output$table <- renderReactable({
    reactable(data = mtcars)
  })
}
shinyApp(ui, server)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants