首页 > 解决方案 > 如何在闪亮的应用程序中包含 html/css

问题描述

下面是闪亮的应用程序,如果我需要在其中添加一些 CSS(附在下面),我可以在哪里添加它以便它在 r 闪亮的应用程序中呈现

css

<style>
    .bs-example{
        margin: 60px;
    }
</style>

用户界面

library(shiny)
shinyUI(fluidPage(

    titlePanel("Stateful"),

    # Sidebar with a slider input for number of bins
    sidebarLayout(
        sidebarPanel(

        ),

        # Show a plot of the generated distribution
        mainPanel(
            tabsetPanel(
                id="inTabset",
                tabPanel("Tab 1",actionButton("switch_tab", "Go to the third tab")),
                tabPanel("Tab 2", "there!"),
                tabPanel("Tab 3", "there!"))

        )
    )
))

服务器.R

library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

})

标签: htmlcssrshiny

解决方案


您可以在 ui 部分添加您的 CSS 文件,如下所示:

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

请记住,您的 CSS 文件应该位于闪亮应用程序的 www 目录中。


推荐阅读