Reproducible example:
require(shiny) runApp(list(ui = pageWithSidebar( headerPanel("Example"), sidebarPanel( sliderInput("index", label = "Select a number", min = 1, max = 4, step = 1, value = 2)), mainPanel( htmlOutput("text") )), server = function(input, output) { output$text <- renderUI({ HTML(paste(c("banana","raccoon","duck","grapefruit"))) }) } ))
I would like to have the word corresponding to index ("raccoon" in the default) displayed in bold and the other words in normal font.
If I do:
HTML( <b>paste(c("banana","raccoon","duck","grapefruit")[input$index])<\b>, paste(c("banana","raccoon","duck","grapefruit")[setdiff(1:4,input$index)]) )
I receive an error (<
is not recognized)...
shiny::tags is a list of 110 functions. Each function builds a specific HTML tag. If you are familiar with HTML, you will recognize these tags by their names. You can build UI by using HTML tags.
Shiny has many functions that can transform plain text into formatted text. Simply place text inside the h1() function to create a primary header (e.g. a title), h2() for a secondary header, strong() to make text bold, em() to make text italicized, or any of the other formatting functions.
To bold the text in HTML, use either the strong tag or the b (bold) tag. Browsers will bold the text inside both of these tags the same, but the strong tag indicates that the text is of particular importance or urgency. You can also bold text with the CSS font-weight property set to “bold.”
One more try, is this helpful?
require(shiny) fruits <- c("banana","raccoon","duck","grapefruit") runApp(list(ui = pageWithSidebar( headerPanel("Example"), sidebarPanel( sliderInput("index", label = "Select a number", min = 1, max = 4, step = 1, value = 2)), mainPanel( htmlOutput("text") )), server = function(input, output) { output$text <- renderUI({ fruits[input$index] <- paste("<b>",fruits[input$index],"</b>") HTML(paste(fruits)) }) } ))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With