Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny - Draw Right Border Of Column

Tags:

html

r

shiny

Suppose I have the following Shiny ui code:

fluidRow(
  column(
    width=4
  ),

  column(
    width=8
  )
)

How can I draw the right border of the first column?

like image 885
Xam Eseerts Avatar asked Mar 04 '18 17:03

Xam Eseerts


2 Answers

You can add CSS to the column using the style argument. So one way to do this would be:

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(style='border-right: 1px solid red',
      width=4,
      p('Hello')
    ),

    column(
      width=8,
      p('World')
    )
  )
)

server <- function(input,output) {}

shinyApp(ui,server)

Hope this helps!

like image 104
Florian Avatar answered Nov 18 '22 10:11

Florian


Another way to approach this is to create the html style outside of the object (the column in this case) and assign the column a css class. By creating the style in this way, you can apply the style to another column more efficiently.

library(shiny)

ui <- fluidPage(
tags$head(
tags$style(HTML("
  
  .column_w_bar {
      border-right-color: #eb4034;
      border-right-width: 1px;
      border-right-style: solid;
}
") # end HTML
) # end tags$style
) # end tags$head

fluidRow(
  column(class = 'column_w_bar',
      width=4
  ),

  column(
      width=8
  )
 ) # end fluidRow
) # end FluidPage

In this example, it is within the R code using tags$head() and tags$style().
You can also create the styles in a separate .css file within the 'www' folder in a shiny project.

like image 1
DanWaters Avatar answered Nov 18 '22 11:11

DanWaters