[英]R Shiny: Interactively modify application theme
我試圖找到一種從文本輸入交互式修改應用程序主題的方法。
這是我的ui.R.的一個例子。
shinyUI(fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),theme = input$skin
)
)
我收到以下錯誤:“錯誤:對象'輸入'未找到”
作為最后一點,我在app文件夾中創建了一個foler www,其中包含bootstrap1.css和其他css文件。
fluidPage
的theme
選項是插入一個帶有以下調用的CSS腳本:
tags$head(tags$link(rel = "stylesheet", type = "text/css",
href = input$Skin))
你可以在你的ui中添加這個html作為一個反應元素:
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))
})
}
))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.