Home > Mobile >  Set font size and color in the second line of string in shiny app
Set font size and color in the second line of string in shiny app

Time:12-14

In the shiny app below I want to change the font size and color of only the word "world" in the second line of my text. How is this possible?

require(shiny)
runApp(
  list(
    ui = pageWithSidebar(
      headerPanel("multi-line test"),
      sidebarPanel(
        p("Demo Page.")
      ),
      mainPanel(
        htmlOutput("text2")
      )
    ),
    server = function(input, output){


      output$text2 <- renderUI({
        HTML(paste("hello", "world", sep="<br/>"))
      })

    }
  )
)

CodePudding user response:

Replace "world" with

"<span style='font-size: 30px; color: red;'>world</span>"

CodePudding user response:

You can solve this using HTML tags inside the renderUI element:

output$text2 <- renderUI({
HTML(paste("hello", "<font size='18px' color='#1ba8a8'>world</font>", sep="<br/>"))
})

enter image description here

  • Related