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",...)
)
Related
I want the selectInput on the same line as the box's title, as in the figure below
I'm trying to put the selectInput inside the title of a bs4Dash::box() with code below.
I'm using the tags$p with "display: inline" but it's not getting align with the box's title.
# library
library(shiny)
library(bs4Dash)
#UI
shinyApp(
ui = dashboardPage(
title = "Reproducible example",
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
fluidRow(
bs4Dash::box(
title = p("Header title",
shiny::selectInput("input_1",
"",
choices = c("choice_1", "choice_2")),
style = "display: inline"
),
width = 12
)
)
)
),
#SERVER
server = function(input, output) {
}
)
Anyone have any work arounds?
I have a need of having the icon in valueBoxes centered. Can that be done?
Here is a snippet with my aproach
library(shiny)
library(shinydashboard)
header <- dashboardHeader()
sidebar <- dashboardSidebar(disable = TRUE)
body <- dashboardBody(
tags$head(tags$style(HTML('.small-box .icon-large {top: 5px;}'))),
valueBox(
value = "Test",
subtitle = NULL,
icon = tags$div(class = "fas fa-thumbs-down", style="text-align:center")
)
)
shinyApp(
ui = dashboardPage(header, sidebar, body),
server = function(input, output){}
)
Here's one way using a CSS trick.
library(shiny)
library(shinydashboard)
header <- dashboardHeader()
sidebar <- dashboardSidebar(disable = TRUE)
body <- dashboardBody(
tags$head(tags$style(HTML('.small-box .icon-large {top: 5px;}'))),
valueBox(
value = "Test",
subtitle = NULL,
icon = icon("fas fa-thumbs-down",
style = "position:relative;right:200px;bottom: 15px")
)
)
shinyApp(
ui = dashboardPage(header, sidebar, body),
server = function(input, output){}
)
You may further adjust right and bottom property as per your requirement.
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 put an image as title of my shiny dashboard and I have adjusted its size in order to fit in height and width but there is a small section in the left side which remains empty. How can I make it fit exactly in the box? (The blue part of the attached image remains empty)
# app.R ##
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(DT)
library(shinyWidgets)
library(shinyjs)
dbHeader <- dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears",
fixed = T,
title = tags$a(href='http://mycompanyishere.com',
tags$img(src='logo.png',height = "55px",width="232px"))
)
ui <- dashboardPagePlus(
dbHeader,
dashboardSidebar(),
dashboardBody(
useShinyjs(),
tags$hr(),
tabsetPanel(
id ="tabA",
type = "tabs",
tabPanel("Front",icon = icon("accusoft")),
tabPanel("Data", icon = icon("table")
)
)
),
rightsidebar = rightSidebar()
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
In order to do this, you need to modify dashboard CSS (i.e. padding). One way would be to insert
tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),
inside dashboardBody()
Then the output looks like this (I don't have your logo but from an image below, you can see that blue part is gone).
For more on how to style apps in Shiny see here: https://shiny.rstudio.com/articles/css.html
I am working in an application similar to one below. I have my input panel in sidebar under a menu which is initally expanded. I want to collapse the menu and hide all the input panel so that my sidebar will be clean. But It should appear when I expand (not permanently hide). I tried the following solution but it is not working. Please help me to find a solution or any alternative approach.
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
startExpanded = TRUE,
"Menu 1",
column(
width = 12,
actionButton("hideMe", label = "Collapse Me", icon = icon("close"))
)
)
)
),
body = dashboardBody()
)
server <- function(input, output, server){
observeEvent(input$hideMe, {
shinyjs::hide(selector = "ul.menu-open");
})
}
runApp(shinyApp(ui, server))
You need to add useShinyjs() into ui part
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(
useShinyjs(),
sidebarMenu(
menuItem(
startExpanded = TRUE,
"Menu 1",
column(
width = 12,
actionButton("hideMe", label = "Collapse Me", icon = icon("close"))
)
)
)
),
body = dashboardBody()
)
server <- function(input, output, server){
observeEvent(input$hideMe, {
shinyjs::hide(selector = "ul.menu-open");
})
}
runApp(shinyApp(ui, server))