I'm trying to add a style in shiny
but when I check Chrome
it shows up as #input-label + div > div {width: 150px}
, >
should actually be >
. What is causing this?
library(shiny)
ui <- fluidPage(
tags$style("#input-label + div > div {width: 150px;}"),
numericInputIcon("input", "input", 42, icon = "Num")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
The issue is that you pass a character string which gets escaped, i.e. the >
is replaced by the HTML entity >
. To prevent that you have to wrap in HTML()
so that
the
tag()
function will know not to perform HTML escaping on it. (See?htmltools::HTML
).
This is also mentioned in the docs (see ?tags
) according to which ...
may include
HTML()
strings
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$style(HTML("#input-label + div > div {width: 150px;}")),
numericInputIcon("input", "input", 42, icon = "Num")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
#>
#> Listening on http://127.0.0.1:6399