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

Consider removing empty .shiny-html-output containers from document flow in fillable containers #434

Open
gadenbuie opened this issue Aug 20, 2024 · 0 comments · May be fixed by #435
Open

Comments

@gadenbuie
Copy link
Member

In a filling context, empty .shiny-html-output containers either receive gap or are included in the allocation of space in the flex container, leading to additional space that most people would not expect to appear. Consider conditional dynamic content shown in a sidebar() or conditional content shown in a card.

In the following example, the intention is to hide the reactable table unless the card is in full-screen

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

ui <- page_fluid(
  card(
    id = "table_card",
    "A fancy table",
    uiOutput("ui_table", fill = TRUE),
    full_screen = TRUE
  ),
  # tags$style(HTML(".html-fill-container .shiny-html-output:empty { position: absolute }"))
)

server <- function(input, output) {
  output$ui_table <- renderUI({
    req(input$table_card_full_screen)
    reactableOutput("table")
  })
  
  output$table <- renderReactable({
    reactable(mtcars)
  })
}

shinyApp(ui = ui, server = server)

The card contains an additional row of space that most people would not expect or want.

image

If we move the empty element out of the document flow, it's no longer accounted for in the flex calculation:

.html-fill-container .shiny-html-output:empty { 
  position: absolute 
}

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

Successfully merging a pull request may close this issue.

1 participant