0
output$abstractText <- renderUI({
tags$div(
   HTML(
      paste("",
            "<span style='font-size: 30px; "Text",
            "",  
            "This tool has been developed by the ",
            tags$a(href = "https://www.","hyperlinked text"),
            ". For news and updates, follow us on Twitter ", 
            tags$a(href = "https://twitter.com", "@xyz"),
            "",

From "This tool..." on it appears in 4 lines - how can I have it in one line only?

thothal
  • 16,690
  • 3
  • 36
  • 71
JuLo
  • 3
  • 1
  • Welcome to SO! After reformatting your code, you see that there are some parts missing and the example is not really reproducible. [Please read and follow the recommendations of how to make an example reproducible.](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Furthermore, after the reformatting you see that the span is also flawed (no closing `'`...) – thothal Jul 20 '23 at 07:10

1 Answers1

0

Difficult to say without your full code, but the following example illustrates how you can do that.

You most likely won't need paste and no need to mark the elements with HTML as htmltools will properly render the content. Furthermore, you barely need to create HTML tags by strings ("<span href=...") but you can (and should) simply use the wrappers from library htmltools (which is automatically loaded when loading shiny).

Having said that, the following snippet shows that all the text is properly in one line:

library(shiny)

ui <- fluidPage(uiOutput("link"))

server <- function(input, output, session) {
   output$link <- renderUI({
      div(
         span(
            style = "font-size: 30px",
            "Text",
            tags$a(
               href = "https://www.google.com",
               "Hyperlink Text"
            ),
            "For news and updates, follow us on ",
            tags$a(
               href = "https://twitter.com", 
               "Twitter"
            ) 
         )
      )
   })
}

shinyApp(ui, server)

Screenshot of the rendered shiny output showing that the content is in one line as intended by the OP

thothal
  • 16,690
  • 3
  • 36
  • 71