How to add tabulation to a line using htmlOutput()?

I want to add one tabulation to a line in Shiny but I don't find the way to do it.

image 1

I know that there are HTML tags in Shiny such as strong to put words in bold, small to make them smaller... Even blockquote to add blocks of quotes. But I didn't find one to add one tabulation.

Does anyone know how to do it?

Reproducible code:

library(shiny)
ui = pageWithSidebar(
  headerPanel("My app"),
  sidebarPanel(
    
  ),
  mainPanel(
            htmlOutput("text")
  )
)
server = function(input, output) {
  output$text <- renderUI({
    str1 <- strong("This is the first line in bold:")
    str2 <- em("This is the second line in italics and with one tabulation")
                
    HTML(paste(str1, str2, sep = '<br/>'))
    
  })
}

shinyApp(ui,server)

Solution 1:

You can add a style attribute to each shiny-tag:

library(shiny)
ui = pageWithSidebar(
  headerPanel("My app"),
  sidebarPanel(),
  mainPanel(
    htmlOutput("text")
  )
)
server = function(input, output) {
  output$text <- renderUI({
    tag1 <- p(strong("This is the first line in bold:"))
    tag2 <- p(em("This is the second line in italics and with one tabulation"), style = "text-indent: 1em;")
    HTML(paste(tag1, tag2, sep = '<br/>'))
  })
}

shinyApp(ui,server)

result

Solution 2:

You could do it just using html code instead of the r tags from shiny:

library(shiny)
ui = pageWithSidebar(
  headerPanel("My app"),
  sidebarPanel(
    
  ),
  mainPanel(
    htmlOutput("text")
  )
)
server = function(input, output) {
  output$text <- renderUI({
    str1 <- "<p><strong>This is the first line in bold:</strong></p>"
    str2 <- "<p style='text-indent: 45px'><em>This is the second line in italics and with one tabulation</em></p>"
    
    HTML(paste(str1, str2, sep = ''))
    
  })
}

shinyApp(ui,server)

unless I have misunderstood what you're trying to do.

enter image description here