I am trying to find a way to interactively modify the application theme from a text input.
Here is an example of my ui.R.
shinyUI(fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),theme = input$skin
)
)
I am getting the following error: "ERROR: object 'input' not found"
As a final note I have created a foler www within the app folder which does contain bootstrap1.css among other css files.
The theme
option in fluidPage
is inserting a CSS script with the following call:
tags$head(tags$link(rel = "stylesheet", type = "text/css",
href = input$Skin))
You can just add this html as a reactive element in your ui:
library(shiny)
runApp(list(ui = fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("Skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),
uiOutput("myUI")
)
, server = function(input, output, session){
output$myUI <- renderUI({
tags$head(tags$link(rel = "stylesheet", type = "text/css",
href = input$Skin))
})
}
))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.