I'm trying to increase the height of a select input inside the sidebar of a shinydashboard. When started, the height is correct, but immediatly, the size decrease to the default one.
I try use tags$style :
tags$style(type='text/css', "#input_id {height: 100px}")
Here is a reproductible example :
library(shiny)
library(shinydashboard)
# Define UI for application that draws a histogram
ui <- dashboardPage(
title = "Plan de gestion",
dashboardHeader(
title = "test"
),
dashboardSidebar(
sidebarMenu(
selectInput(inputId = "test_size", label = "Test", choices = c("A", "B", "C")),
tags$style(type='text/css', "#choix_param {height: 100px}")
)
),
dashboardBody(
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)
Thank you for your help.
I find the solution :
tags$head(tags$style(HTML("#test_size+ div>.selectize-input {min-height: 500px}")))
Related
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 trying to put an image inside the infoBox of a shinyApp.
I am getting this error:
Error in shinyUI(dashboardPage, dashboardHeader("ABC"),
dashboardBody(fluidPage(h1("type"), : unused arguments
(dashboardHeader("ABC"), dashboardBody(fluidPage(h1("type"),
mainPanel(tabsetPanel(tabPanel(h1("summary"), infoBox("BCD", a,
div(img(src = "ribbon.PNG", width = 100), style = "text-align:
center;"))))))))
Code:
library(shiny)
library(shinydashboard)
a = 45
ui < - shinyUI(dashboardPage,
dashboardHeader("ABC"),
dashboardBody(fluidPage(h1("type"),
mainPanel(
tabsetPanel(
tabPanel(h1("summary"),
infoBox("BCD", a, div(img(src = "ribbon.PNG",
width = 100), style = "text-align: center;"))))))))
server <- shinyServer({})
shinyApp(ui, server)
Can anyone help me on this?
Set an image img.png in the www folder and then the code below works :
library(shiny)
library(shinydashboard)
a <- 45
ui <- shinyUI(
dashboardPage(
dashboardHeader(title = "ABC"),
dashboardSidebar(),
dashboardBody(
fluidPage(
infoBox("BCD", a, div(img(src = "img.png", width = 100), style = "text-align: center;"))
)
)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
In my current application I am using a navlistPanel similar to the one below and I was wondering whether it would be possible to add a selectInput UI element to the navlist?
I have tried this in my ui.R but it doesn't work:
fluidPage(
titlePanel("Application Title"),
navlistPanel(
"Header",
tabPanel("First"),
tabPanel("Second"),
tabPanel("Third")
# selectInput(inputId, label, choices, selected = NULL) <- I've tried this but it doesn't work
)
)
Any solutions/workarounds are welcome.
I was wondering whether using sidebarLayout + sidebarPanel would work where the sidebarPanel imitates the behaviour of a navlistPanel but wasn't able to implement it.
A clean solution will be difficult, but how about something like this:
library(shiny)
shinyApp(
ui <- fluidPage(
titlePanel("Application Title"),
navlistPanel("Header", id = "navOut",
tabPanel("First", "First"),
tabPanel(selectInput("navSel", "Selection:", c("b", "c")), textOutput("txt"))
)
),
server <- shinyServer(function(input, output){
output$txt <- renderText(input$navSel)
})
)
If you are okay with using shinydashboard, it is fairly simple.
library(shiny)
library(shinydashboard)
rm(list=ls)
######/ UI Side/######
header <- dashboardHeader(title = "Test")
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("First Tab",tabName = "FTab", icon = icon("globe")),
menuItem("Second Tab",tabName = "STab", icon = icon("star"))
),
selectInput("navSel", "Selection:", c("b","c"))
)
body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body)
######/ SERVER Side/######
server <- function(input, output, session) {
}
shinyApp(ui, server)
The given R shiny script has a selectInput and infobox below, I just want to display the selected value in the selectInput within the infobox in the ui. Please help me with a solution and if possible, kindly avoid any scripting in the sever as I have furthur dependency. If this can be done within the UI, would be great, thanks.
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", status = "primary", solidHeader = T, width = 12,
fluidPage(
fluidRow(
column(2,offset = 0, style='padding:1px;',
selectInput("select the
input","select1",unique(iris$Species)))
))),
infoBox("Median Throughput Time", iris$Species)))
server <- function(input, output) { }
shinyApp(ui, server)
Trick is to make sure you know where the value of the selectInput is being assigned, which is selected_data in my example, this can be referenced within the server code by using input$selected_data.
renderUI lets you build a dynamic element which can be rendered with uiOutput and the output id, in this case, info_box
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", status = "primary", solidHeader = T, width = 12,
fluidPage(
fluidRow(
column(2, offset = 0, style = 'padding:1px;',
selectInput(inputId = "selected_data",
label = "Select input",
choices = unique(iris$Species)))
)
)
),
uiOutput("info_box")
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$info_box <- renderUI({
infoBox("Median Throughput Time", input$selected_data)
})
}
# Run the application
shinyApp(ui = ui, server = server)
My problem is that I told shiny to take all the line (12 columns) to print c7 box but it only uses half of it. Can anyone figure out what is the problem? Following is my code:
library(shinydashboard)
library(shiny)
library(readr)
library(rsconnect)
header=dashboardHeader(title="App")
sidebar=dashboardSidebar(sidebarMenu(
menuItem("Stack", tabName = "a", icon = icon("dashboard"))))
c7=column(12,box(title="Prediction Box",status="warning",solidHeader=FALSE,
textInput("text", label = h3("Write something :"), value = ""),actionButton("do","Go")))
body=dashboardBody(tabItems(tabItem(tabName="a",fluidRow(c7))))
ui <- dashboardPage(header,sidebar,body)
server <- function(input, output){
}
shinyApp(ui,server)
By default, if you're not specifying the width of the box it will be set to 6. Have a look at ?box
E.g.:
library(shinydashboard)
library(shiny)
header=dashboardHeader(title="App")
sidebar=dashboardSidebar(sidebarMenu(menuItem("Stack", tabName = "a", icon = icon("dashboard"))))
?box
c7=column(12,box(width=12,title="Prediction Box",status="warning",solidHeader=FALSE,
textInput("text", label = h3("Write something :"), value = ""),actionButton("do","Go")))
body=dashboardBody(tabItems(tabItem(tabName="a",fluidRow(c7))))
ui <- dashboardPage(header,sidebar,body)
server <- function(input, output){
}
shinyApp(ui,server)