Open echoplaza opened 1 year ago
I have it working with the code here (below) but why is there a red "1" icon above the "Select page" dropdown?
library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
header = dashboardHeader(
title = "My Shiny App",
leftUi = tagList(
dropdownBlock(
id = "menu",
title = "Select page",
icon = icon("list-alt"),
selectInput("menu", label = NULL,
choices = c("Data", "Visualize"),
selected = "Data"
)
)
)
),
sidebar = dashboardSidebar(
uiOutput("sidebar_content")
),
body = dashboardBody(
uiOutput("page_content")
)
)
server <- function(input, output) {
output$sidebar_content <- renderUI({
if (input$menu == "Data") {
sidebarMenu(
menuItem("Data Page", tabName = "data_page")
)
} else {
sidebarMenu(
menuItem("Visualize Page", tabName = "visualize_page")
)
}
})
output$page_content <- renderUI({
if (input$menu == "Data")
{
box(title = "data box")
} else
{
box(title = "viz box")
}
})
}
shinyApp(ui, server)
I'm trying to get both the page and sidebar to change based on the selectInput using renderUI and uiOutput.
Here is a very simple reprex wherein the server's renderUI function operates based on the selectInput to render either a "data" or a "visualize" page and sidebar.
But running the App returns this error: "Error in dashboardHeader(title = "My Shiny App", tags$li(class = "dropdown", : attempt to apply non-function"
Any ideas? Should this be possible?
Thanks,
echo