简体   繁体   English

向 SidebarPanel 和 MainPanel 添加黑色边框 - R Shiny

[英]Add Black Border to SidebarPanel and MainPanel - R Shiny

How would I add a black boarder to the main panel and side bar panel for the MRE?我如何在 MRE 的主面板和侧边栏面板上添加黑色边框? I would like the panels to stand out slightly more.我希望面板稍微突出一点。 I have adjusted background color on my app but think adding a black boarder will make each panel stand out better.我已经调整了我的应用程序的背景颜色,但我认为添加黑色边框会使每个面板更加突出。

UI用户界面

library(shiny)
library(shinyalert)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

    # Application title
    titlePanel("Old Faithful Geyser Data"),

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

        # Show a plot of the generated distribution
        mainPanel(
          DT::dataTableOutput("cap_table"),

        )
    )
))


Server服务器

library(shiny)
library(shinyalert)

data <- data.frame(x=rnorm(10),y=rnorm(10))

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


  
  # render data selection
  output$cap_table <- DT::renderDataTable(data)

    

})

You may consider adding custom css to your app.您可以考虑将自定义 css 添加到您的应用程序。 I right click the app when it's running to "inspect" the css class that I would like to change.我在应用程序运行时右键单击它以“检查”我想更改的 css class。

Here is an example using in-line code.这是一个使用内联代码的示例。

Here is a link to consider other approaches such as sourcing a css file.这是考虑其他方法的链接,例如获取 css 文件。 https://shiny.rstudio.com/articles/css.html https://shiny.rstudio.com/articles/css.html

library(shiny)
library(DT)

# Define UI for application that draws a histogram
ui <- shinyUI(
  fluidPage(
  tags$head(
    # Note the wrapping of the string in HTML()
    tags$style(HTML(".well {
        border: 1px solid #000000;
      }")), 
    tags$style(HTML(".col-sm-8 {
        border: 1px solid #000000;
      }"))
  ),
  # Application title
  titlePanel("Old Faithful Geyser Data"),
  
  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      
    ),
    
    # Show a plot of the generated distribution
    mainPanel(
      DT::dataTableOutput("cap_table"),
      
    )
  )
))


data <- data.frame(x=rnorm(10),y=rnorm(10))

# Define server logic required to draw a histogram
server <- shinyServer(function(input, output) {
  
  
  
  # render data selection
  output$cap_table <- DT::renderDataTable(data)
  
  
  
})

shinyApp(ui = ui, server = server)

样本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM