I try to create a shiny app using dashboardPagePlus.
I already import shinydashboard and shinydashboardPlus package. But I got an error message when I run UI.
Error in dashboardPagePlus(skin = "black", dashboardHeaderPlus(title =
"title"), : could not find function "dashboardPagePlus"
I don`t know why. I try to run the example code from RDocumentation. But Still have this problem.
Example code:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears"
),
sidebar = dashboardSidebar(),
body = dashboardBody(),
rightsidebar = rightSidebar(),
title = "DashboardPage"
),
server = function(input, output) { }
)
How to fix it?
Thank you very much.
As already mentioned in the comments, if you use {shinydashboardPlus} >= 2.0.0, you would need to rewrite your code as follows:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(),
controlbar = dashboardControlbar(
skin = "dark",
controlbarMenu(
id = "menu"
)
),
title = "DashboardPage"
),
server = function(input, output) { }
)
Related
I'm trying to have a box inside my shiny app while using the shinythems library :
library(shiny)
library(DT)
library(shinythemes)
library(shinydashboard)
ui <- fluidPage(
theme = shinytheme("lumen"),
navbarPage("test theme",
tabPanel("tab1",
mainPanel(width = 12,
fluidRow(
box(width=6,title = "title",status = "navy", solidHeader = TRUE,
dataTableOutput(outputId = "tab"))))
))
)
)
Server <- function(input, output,session){
output$tab = renderDataTable(mtcars)
}
shinyApp(ui, server)
But it does not work as I expected !
I was hoping to get something like :
I tried the titlePanel as well but it did not work !
I don't believe you can mix-n-match Shiny fluidPage, shinythemes & elements from shinydashboard just like that. For box to properly work it needs shinydashboard CSS and to include this you'd normally use
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody()
)
layout instead of fluidPage() / fixedPage() Shiny layouts.
Though.. there's shinyWidgets::useShinydashboard() :
library(DT)
library(shiny)
library(shinythemes)
library(shinydashboard)
library(shinyWidgets)
ui <- fluidPage(
theme = shinytheme("lumen"),
shinyWidgets::useShinydashboard(),
navbarPage("test theme",
tabPanel("tab1",
mainPanel(width = 12,
fluidRow(
box(width = 12,
title = "title", status = "warning", solidHeader = TRUE,
dataTableOutput(outputId = "tab")
)
)
)
)
)
)
server <- function(input, output, session) {
output$tab <- renderDataTable(mtcars)
}
shinyApp(ui, server)
DT might not be the best example here as it requires some setup for responsiveness (it doesn't respect box boundaries and box(width = 6, ...) just draws over half of the table).
I have shiny application with box in the body as shown below:
library(shiny)
library(shinydashboard)
body <- dashboardBody(
fluidRow(box(
title = "My header1",
id = "box1", solidHeader = TRUE,
infoBox(title = "My header2", value = NULL,
icon = shiny::icon("calendar"),width = 12,
href = NULL)
)
))
shinyApp(
ui = dashboardPage(
dashboardHeader(title = "Boxes"),
dashboardSidebar(),
body
),
server = function(input, output) {
}
)
How can i place the infoBox() next to the box title "My header1" ? so that they are in the same line as indicated below?
so that it looks like:
I am using shinydashboardPlus because I want to use dashboardFooter, but I removed the sidebar. the problem is that the logo header/sidebar header is still there, and haven't figure out a way to remove it. I tried to solve the issue by changing my css script, with no luck. The image shows what I want to remove:
Here is a simple, reproducible example:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyWidgets)
library(shinyjs)
header <- dashboardHeader(tags$li(class = "dropdown",
sidebarMenu(
id = "mysearch",
menuItem(
text = "Main",
tabName = "main",
icon = icon("home")
)
)))
sidebar <- dashboardSidebar(
width = "0px"
)
body <- dashboardBody()
ui <- (dashboardPage(
header = header,
sidebar = sidebar,
body,
footer = dashboardFooter(
left = tags$b(
icon("envelope"),
tags$a(href = "mailto:", "myemail#email.no"),
icon("home"),
tags$a(href = "https://somesite.no", "www.somesite.no/")
),
right = ""
)
))
server <- function(input, output, session) {}
shinyApp(ui, server)
Any ideas?
Try titleWidth=0, as
header <- dashboardHeader(
titleWidth=0,
tags$li(class = "dropdown",...)
)
I want to put a dropdown menu on shinydashboard header for dashboard theme change. My shiny app is like below. I could not make the app work. What I got is error message;
Error in FUN(X[[i]], ...) : Expected tag to be of type li
It seems like the dashboard area does not accept those typical shiny widgets? The header area is the best place to put this functionality. Does anyone know how I can make that work? Thanks a lot.
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(dashboardthemes)
header <- dashboardHeader(
title = "Dashboard Demo",
dropdownButton(
tags$h3("List of Themes:"),
radioButtons(inputId = 'theme',
label = 'Dashboard Theme',
choices = c('blue_gradient', 'boe_website', 'grey_light','grey_dark',
'onenote', 'poor_mans_flatly', 'purple_gradient'),
selected = 'grey_dark',
inline=FALSE),
circle = TRUE, status = "primary",
icon = icon("window-maximize"), width = "300px",
tooltip = tooltipOptions(title = "Click to change dashboard theme")
)
)
shinyApp(
ui = dashboardPage(
header,
dashboardSidebar(),
dashboardBody(
shinyDashboardThemes(
theme = input$theme
),
)
),
server = function(input, output) { }
)
You can not put the dropdownButton in the dashboardHeader.
Instead you can put it in the dashboardBody or dashboardSidebar and have it updated like this :
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(dashboardthemes)
shinyApp(
ui = dashboardPage(
dashboardHeader(title = "Dashboard Demo"),
dashboardSidebar(),
dashboardBody(
dropdownButton(
radioButtons(inputId = 'theme',
label = 'Dashboard Theme',
choices = c('blue_gradient', 'boe_website', 'grey_light','grey_dark',
'onenote', 'poor_mans_flatly', 'purple_gradient'))
),
uiOutput("myTheme")
)
),
server = function(input, output) {
output$myTheme <- renderUI( shinyDashboardThemes(theme = input$theme))
}
)
I have a basic shiny dashboard below and I would like to know if I can a little bit left or right the bs button "show/hide sidebar".
#ui.r
library(shinydashboard)
library(shiny)
library(shinyBS)
dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = TRUE),
dashboardBody(
tabsetPanel(
id = 'testingDPEtab',
tabPanel("Upload",
bsButton("showpanel8", "Show/Hide sidebar",icon = icon("toggle-off"), type = "toggle",style = "info", value = TRUE),
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody())
)
)
))
#server.r
server <- function(input, output) { }
Depending on whether you want to apply the "moving" to a specific button or for all these buttons you can do:
tags$head(
tags$style(HTML('#showpanel8{margin-left:10px}'))
)
Here, the button is referenced by id. So the change will only apply to that button.
#showpanel8{margin-left:10px} is CSS syntax to style the button.
For other margins you can use:
margin-top
margin-right
margin-bottom
margin-left
See here: https://www.w3schools.com/css/css_margin.asp.
Full reproducible example:
library(shinydashboard)
library(shiny)
library(shinyBS)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = TRUE),
dashboardBody(
tags$head(
tags$style(HTML('#showpanel8{margin-left:10px}'))
),
tabsetPanel(
id = 'testingDPEtab',
tabPanel("Upload",
bsButton("showpanel8", "Show/Hide sidebar",
icon = icon("toggle-off"), type = "toggle",
style = "info", value = TRUE),
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody())
)
)
))
#server.r
server <- function(input, output) { }
shinyApp(ui, server)