How to use shinydashboard elements inside a shiny::fluidPage

2,624 views
Skip to first unread message

msquatrito

unread,
Mar 9, 2017, 10:07:22 AM3/9/17
to Shiny - Web Framework for R
Hi all,
I would like to include some shiny dashboard components, e.g. `box` or `valueBox`, inside a `fluidPage` instead of a `dashboardPage`.
Unfortunately, they are not displayed properly, e.g. no background for the valueBox, boxes cannot be collapsed, etc.  
Is there any work around to solve these issues?
Thanks in advance.
Massimo

msquatrito

unread,
Mar 13, 2017, 7:00:10 AM3/13/17
to Shiny - Web Framework for R
Below is a MRE, in case someone has any idea on how to do it. I guess, I have to include some `tag` at the beginning of the script or to wrap the output inside a specific `div`, but i'm not sure of what should I add. Thanks.

library(shiny)
library
(shinydashboard)

# shiny UI
ui_s
<- fluidPage(
  fluidRow
(
    valueBoxOutput
("BoxDown", width = 4),
    valueBoxOutput
("BoxUp", width = 4)
 
)
)

# shinydashboard UI
ui_db
<- dashboardPage(
  dashboardHeader
(),
  dashboardSidebar
(),
  dashboardBody
(
    fluidRow
(
      valueBoxOutput
("BoxDown", width = 4),
      valueBoxOutput
("BoxUp", width = 4)
   
)
 
)
)

# server
server
<- function(input, output) {
  output$BoxUp
<- renderValueBox({
    valueBox
(
      value
= 100,
      subtitle
= "Upregulated",
      icon
= icon("arrow-up"),
      color
= "red"
   
)
 
})
 
  output$BoxDown
<- renderValueBox({
    valueBox
(
      value
= 50,
      subtitle
= "Downregulated",
      icon
= icon("arrow-down"),
      color
= "olive"
   
)
 
})
}


# Run the shiny app
shinyApp
(ui_s, server)

# Run the shinydashboard app
shinyApp
(ui_db, server)

Joe Cheng

unread,
Mar 13, 2017, 8:15:02 PM3/13/17
to msquatrito, Shiny - Web Framework for R
Sorry, the shinydashboard elements are only designed to be used inside of dashboardPage. This is the only way the dashboard CSS assets will be loaded.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/92c53589-8177-4b6a-b2e6-fc1f1e961704%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Diana Van Der Plaat

unread,
Feb 5, 2019, 7:24:47 AM2/5/19
to Shiny - Web Framework for R
Maybe you already solved this problem, but everyone currently with the same question, this page will help (it is possible now to use dashboard components in fluidpage) : https://www.rdocumentation.org/packages/shinyWidgets/versions/0.4.4/topics/useShinydashboard 

Op donderdag 9 maart 2017 15:07:22 UTC schreef msquatrito:
Reply all
Reply to author
Forward
0 new messages