Shiny plotly sizing issue for plotlyOutput() when width = 100%
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When using the default width = 100% for plotlyOutput() in Shiny apps, I always run into issues where the width doesn't scale to the full width when clicking away before the plot is fully rendered. When clicking back, the plot's width doesn't adjust or rescale. This setting occurs often in practice when designing a shinydashboard with multiple tabItems(). Minimal example and a GIF to better explain what I mean below. Posting it here, but please advise if this should be an htmlwidgets or shiny issue instead.

library(shiny)
library(plotly)
ui <- navbarPage(
title = "Minimal Example",
tabPanel("Home", HTML("Click the `Plot` tab and then rapidly back on the `Home` tab. Wait 2 seconds and then click the `Plot` tab again.")),
tabPanel("Plot", plotlyOutput("plot"))
)
server <- function(input, output) {
output$plot <- renderPlotly({
Sys.sleep(2)
plot_ly(iris, x = ~Sepal.Width, y = ~Sepal.Length, type = "scatter", mode = "markers")
})
}
shinyApp(ui, server)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided minimal R Shiny example and reproducing the tab-switching behavior with plotlyOutput() and renderPlotly(). Investigate whether the sizing issue belongs in plotly.R, htmlwidgets, or Shiny; done means the plot expands to the full width after returning to its tab, even when rendering was delayed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- plotly, r
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100