Reputation:
ui <- fluidPage(
radioButtons("dist", "Distribution type:",
c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp")))
server <- function(input, output) {}
I would like the font colors of "Normal" and "Uniform" to be different than those of the other choices. Let's say the color of the first two choices should be red.
Anyone who can achieve that?
Upvotes: 2
Views: 3546
Reputation: 7685
Just look at the examples in ?radioButtons
. This will give you instructions on how to apply HTML
tags to choices.
To summarize, you will have to use the arguments choiceNames
and choiceValues
.
choiceNames
defines the ui of your radiobuttons. You can use HTML
tags (tags$strong
, tags$code
, ... and HTML("some html string")
)choiceValues
are the values that will be recieved by the server via input$dist
.Here is an example:
library(shiny)
shinyApp(
fluidPage(
radioButtons(
inputId = "dist",
label = "Distribution type:",
choiceNames = list(
HTML("<font color='red'>Normal</font>"),
tags$span(style = "color:red", "Uniform"),
"Log-normal", "Exponential"
),
choiceValues = c("norm", "unif", "lnorm", "exp")
)
),
server = function(...) {}
)
Also, take a look at shinyWidgets::shinyWidgetsGallery()
if you need inspiration for the styling of your radioButton
s.
Upvotes: 8