Search code examples
htmlcssrshiny

Avoid line break in the output of R shiny code


In my Code tags$p(HTML("...") is shown in one line in the browser output.

And my question is: How can I achieve a browser output with the two lines tags$strong("strong text") and p(" created with <strong>...</strong>") compared to tags$p(HTML("...")? Any hint how to avoid a line break?

ui <- fluidPage(        
    
    
    # HTML spelling and the output appears in one line       
    tags$p(HTML("
            <strong>strong text</strong> created with the tag &lt;strong&gt;...&lt;/strong&gt;)
    ")),

    # The following two lines of code should appear in the same line in my browser
    tags$strong("strong text"),
    p(" created with <strong>...</strong>")

)

server <- function(input, output, session) {
}

shinyApp(ui, server)

Solution

  • Not sure, but maybe you are looking for this (child tags):

    library(shiny)
    
    ui <- fluidPage(
      # HTML spelling and the output appears in one line
      tags$p(HTML("<strong>strong text</strong> created with the tag &lt;strong&gt;...&lt;/strong&gt;)")),
      # The following two lines of code should appear in the same line in my browser
      p(tags$strong("strong text"), " created with tags$strong('...')")
      )
    
    server <- function(input, output, session) {}
    
    shinyApp(ui, server)