gpt4 book ai didi

css - R Shiny : Interactively modify application theme

转载 作者:太空狗 更新时间:2023-10-29 12:33:53 24 4
gpt4 key购买 nike

我正在尝试找到一种通过文本输入以交互方式修改应用程序主题的方法。

这是我的 ui.R 示例。

shinyUI(fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),theme = input$skin
)
)

我收到以下错误:“错误:未找到对象‘输入’”

作为最后的说明,我在应用程序文件夹中创建了一个 foler www,其中包含 bootstrap1.css 和其他 css 文件。

最佳答案

fluidPage 中的 theme 选项正在使用以下调用插入 CSS 脚本:

tags$head(tags$link(rel = "stylesheet", type = "text/css", 
href = input$Skin))

您只需将此 html 添加为您的 ui 中的 react 元素即可:

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))
})
}
))

关于css - R Shiny : Interactively modify application theme,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25906723/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com