4

In my shiny app, I have a textOutput named acronym where I would like to renderText some text which is half non-italicized, half-italicized.

I tried doing it like this:

output$acronym_1 <- renderText(paste("SID SIDE:", tags$em("Siderastrea siderea")))

But this did not get the second half in italics. How do I do this? Thanks in advance.

John Smith
  • 393
  • 1
  • 6
  • 17

1 Answers1

2

The following code will produce italicized text

library(shiny)

ui = fluidPage(uiOutput("htmlText"))

server <- function(input, output)
  output$htmlText <- renderUI(HTML(paste(
    "Non-italic text.", em("Italic text")
  )))

shinyApp(ui, server)

I don't think textOutput is capable of text markup since the output string will be created by cat according to the documentation.

renderText(expr, env = parent.frame(), quoted = FALSE, outputArgs = list())

expr An expression that returns an R object that can be used as an argument to cat.

Gregor de Cillia
  • 7,397
  • 1
  • 26
  • 43