Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(R shiny) cannot change the width of infoBox

I use the library shinydashboard to write my ui.R. In my dashboardBody part, I wrote:

fluidRow(infoBoxOutput("dri"))

And then in my server.R, I wrote:

output$dri = renderInfoBox({
    infoBox(
        width = 2,
        title = tags$b("Score"),
        value = tags$b("100"),
        color = "aqua",
        fill = TRUE,
        icon = icon("edit")
    )
})*

But the width won't change to 2; it still uses the default one, i.e. 4 (1/3 of the whole webpage width). Would someone help me with this? Thank you very much!

like image 869
Xin Wang Avatar asked Dec 19 '22 18:12

Xin Wang


2 Answers

Maybe you can style it yourself

rm(list = ls())
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(fluidRow(infoBoxOutput("dri")),tags$style("#dri {width:200px;}"))
)

server <- function(input, output) { 
  output$dri <- renderInfoBox({
    infoBox(
      title = tags$b("Score"),
      value = tags$b("100"),
      color = "aqua",
      fill = TRUE,
      icon = icon("edit")
    )    
  })
}
shinyApp(ui, server)

200 px enter image description here

1000px enter image description here

like image 73
Pork Chop Avatar answered Dec 21 '22 07:12

Pork Chop


I found this answer on github and it worked for me aswell:

Instead of using renderInfoBox and infoBoxOutput, you can use renderUI and uiOutput and that worked for me. This makes me think there is an issue with the renderInfoBox function.

like image 43
Pedrinho Avatar answered Dec 21 '22 07:12

Pedrinho