renderValueBox not showing inside tabItem in Shiny

386 views
Skip to first unread message

Omar André Gonzáles Díaz

unread,
May 13, 2017, 9:48:21 PM5/13/17
to Shiny - Web Framework for R

I want to display a ValueBox within Shiny using ShinyDashboards. 

It does NOT render inside a tabItem, but does outside tabItem


I need to used tabItems, is there a workaround?



#---- This does NOT show anything ----#


##########################################

ui.R

dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    tabItems(tabItem(tabName="TotalTVs",
             valueBoxOutput("vbox")
    )
    )
  )
)


##########################################

server <- function(input, output) {
  
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      200,
      icon = icon("credit-card")
    )
  })
}


#---- This does WORK ----#



##########################################

ui.R


dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
             valueBoxOutput("vbox")
    )
)


##########################################

server <- function(input, output) {
  
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      200,
      icon = icon("credit-card")
    )
  })
}



g inberg

unread,
May 15, 2017, 6:07:19 AM5/15/17
to Shiny - Web Framework for R
Hi Omar,

in the documentation of tabitem (?tabItem), you can find that you should define a menuitem or menusubitem with the same name.

Below code works for me, can you try it?

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(sidebarMenu(menuItem("TotalTVs", tabName = "TotalTVs", icon = icon("dashboard")))),
  dashboardBody(
    tabItems(tabItem(tabName="TotalTVs", valueBoxOutput("vbox")
    )
  )
  )
)

server <- function(input, output) {
  
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      200,
      icon = icon("credit-card")
    )
  })
}

shinyApp(ui = ui, server = server)


best,
Ger
Reply all
Reply to author
Forward
0 new messages