首页 > 解决方案 > Shiny app radioButtons invisible in RStudio viewer pane

问题描述

The RStudio (Version 1.2.1139 on macOS) viewer pane renders radioButtons (and FWIW, selected checkboxInputs) invisible. But these look and work fine in the browser, when 'Run External' is selected under the 'Run App' button. Below is a repro, and some screenshots.

Addendum: I note that shinyWidgets::prettyRadioButtons() resolves this issue immediately. Simply add library(shinyWidgets) at the top, and replace the call to radioButtons().

# Reproduce radioButtons invisibility in RStudio viewer pane
library(shiny)

ui <- fluidPage(
   radioButtons("Dunit"
               ,"Dose Units"
               ,c("µg"="micrograms",
                  "mg"="milligrams",
                  "g"="grams")
               ,selected = "milligrams"
               ,inline = TRUE)
   ,checkboxGroupInput("Dper"
                       ,NULL
                       ,c("/m²"="perBSA",
                          "/kg"="perKg",
                          "abs"="absolute")
                       ,selected = "perKg"
                       ,inline = TRUE)
)

server <- function(input, output) {}

# Run the application 
shinyApp(ui = ui, server = server)

In RStudio viewer pane:

How this Shiny app looks in RStudio viewer pane

In External browser:

How this Shiny app looks in Safari web browser

标签: rshinyrstudio

解决方案


这是 MacOS 上 Chromium(支持 RStudio 查看器的组件)中的一个已知问题。您可以通过添加zoom: 1.0000001或类似于为您的 Shiny 应用设置单选按钮样式的 CSS 来解决此问题。

此 RStudio Github 问题中的更多信息:

https://github.com/rstudio/rstudio/issues/3751


推荐阅读