You can assign a unique class to each box and then specify different CSS for each class. I did that below by creating classes box1 and box2.
library(shiny)
library(shinydashboard)
ui <- fluidPage(
HTML('<style>
.box1 {
border: 1px solid lightgrey;
padding: 5px;
}
.box2 {
border: 10px solid green;
padding: 5px;
height: 350px;
}
</style>'),
br(),
fluidRow(
box(
uiOutput('my_image'),
br(),
uiOutput('my_text'),
br(),
width = 3
),
box(
uiOutput('my_image2'),
br(),
uiOutput('my_text2'),
br(),
width = 3
)
)
)
server <- function(input, output, session) {
# first box content
output$my_image = renderUI({
x = 10
if(x > 5) {letter = 'A'} else {letter = 'F'}
if(x > 5) {color = 'blue'} else {color = 'red'}
HTML(
paste0(
'<div style = "background-color: ', color,';" class = "box1">', # added class
'<br>',
'<center>',
'<font style = "color: black; font-size: 100px;">', letter, '</font>',
'</center>',
'<br>',
'</div>'
)
)
})
output$my_text = renderUI({
HTML('<b>Note</b>: Add text here.')
})
# second box content
output$my_image2 = renderUI({
x = 1
if(x > 5) {letter = 'A'} else {letter = 'F'}
if(x > 5) {color = 'blue'} else {color = 'red'}
HTML(
paste0(
'<div style = "background-color: ', color,';" class = "box2">', # added class
'<br>',
'<center>',
'<font style = "color: black; font-size: 100px;">', letter, '</font>',
'</center>',
'<br>',
'</div>'
)
)
})
output$my_text2 = renderUI({
HTML('<b>Note</b>: Add text here.')
})
}
shinyApp(ui, server)
