Dashboard sidebar menu with uiOutput

565 views
Skip to first unread message

Sigbert Klinke

unread,
Feb 24, 2016, 12:55:47 PM2/24/16
to Shiny - Web Framework for R

Hi,

I'am trying to use uiOutput in dashboard sidebar menu. In the minimal working example below it works as I want when I use sliderInput directly. If I comment the line out and uncomment the uiOutput line then it will not work.

Any ideas what goes wrong?

Thanks in advance

Sigbert

library("shiny")
library
("shinydashboard")

ui
<- dashboardPage(
  dashboardHeader
(title = "MWE"),
  dashboardSidebar
(
    sidebarMenu
(
      menuItem
(text="Optionen",
               
#uiOutput("fontsizeUI")
               sliderInput
('fontsize', label="labla", min=0, max=10, value=5)
               
))),
  dashboardBody
(
   
# Boxes need to be put in a row (or column)
    fluidRow
(
      box
(plotOutput("plot1"), width="420px", height="320px")
   
)
 
)
)

server
<- function(input, output, session) {
  output$fontsizeUI
<- renderUI({ sliderInput('fontsize', label="labla", min=0, max=10, value=5) })
  output$plot1
<- renderPlot({ plot(rnorm(20)) })
}

shinyApp
(ui, server)

MySchizo Buddy

unread,
Feb 24, 2016, 1:29:08 PM2/24/16
to Shiny - Web Framework for R
try this, use sidebarMenuOutput with renderMenu

library
("shiny")
library
("shinydashboard")

ui
<- dashboardPage(
  dashboardHeader
(title = "MWE"),
  dashboardSidebar
(

    sidebarMenuOutput
("fontsizeUI")

   
),
  dashboardBody
(
   
# Boxes need to be put in a row (or column)
    fluidRow
(
      box
(plotOutput("plot1"), width="420px", height="320px")
   
)
 
)
)

server
<- function(input, output, session) {

  output$fontsizeUI
<- renderMenu({
    sidebarMenu
(
      menuItem
("Optionen", sliderInput('fontsize', label="labla", min=0, max=10, value=5))
   
)

MySchizo Buddy

unread,
Feb 24, 2016, 1:35:48 PM2/24/16
to Shiny - Web Framework for R
Another option is to use menuItemOutput


library
("shiny")
library
("shinydashboard")

ui
<- dashboardPage(
  dashboardHeader
(title = "MWE"),
  dashboardSidebar
(
    sidebarMenu
(

      menuItemOutput
("fontsizeUI")

     
)),
  dashboardBody
(
   
# Boxes need to be put in a row (or column)
    fluidRow
(
      box
(plotOutput("plot1"), width="420px", height="320px")
   
)
 
)
)

server
<- function(input, output, session) {

  output$fontsizeUI
<- renderMenu({
    menuItem
("Optionen", sliderInput('fontsize', label="labla", min=0, max=10, value=5))

Sigbert Klinke

unread,
Feb 25, 2016, 3:59:39 AM2/25/16
to Shiny - Web Framework for R
Hi,

is there no way such that I can keep


  output$fontsizeUI <- renderUI({ sliderInput('fontsize', label="labla", min=0, max=10, value=5) })

Thanks a lot

Sigbert

Sigbert Klinke

unread,
Feb 25, 2016, 4:01:50 AM2/25/16
to Shiny - Web Framework for R
With another function call then "renderUI"
Reply all
Reply to author
Forward
0 new messages