11

I want put multiple line breaks in my shiny app. Instead of

br(),
br(),
br(),
...

is there any more convenient way of doing it?Thanks.

Filnor
  • 1,290
  • 2
  • 23
  • 28
rankthefirst
  • 1,370
  • 2
  • 14
  • 26
  • The easiest way would be to modify your css https://stackoverflow.com/questions/2703601/how-to-give-line-break-from-css-without-using-br – amrrs Oct 04 '17 at 07:53
  • Maybe this: https://stackoverflow.com/questions/25340847/control-the-height-in-fluidrow-in-r-shiny – user5029763 Oct 05 '17 at 17:44
  • Seems pretty convenient to me - only 5 characters and stays in the Shiny idiom (no javascript). What kind of convenience are you looking for? – Mike Wise Nov 20 '17 at 08:47
  • @MikeWise Like 10 lines of breaks......putting 10 lines of `br(),` doesn't really cost too much, but that's not what programming does...is it? Programming is supposed to do these repetitive things as I understand... – rankthefirst Nov 21 '17 at 09:50

1 Answers1

14

I have no idea if that's convenient for you, but it saves you some typing.

linebreaks(n) repeats <br/> n times and parses it as HTML.

library(shiny)


linebreaks <- function(n){HTML(strrep(br(), n))}

ui <- fluidPage(

  titlePanel(
              p( 
                  h1("first sentence", align = "center"),

                  linebreaks(10),

                  h3("second sentence", align = "center")
                )
              )
  )

Humpelstielzchen
  • 6,126
  • 3
  • 14
  • 34