Shiny: break line in button label (Solved)

Hi everyone,
Please see the following toy example. Any help would be greatly appreciated! Thanks!

shinyApp(
ui = fluidPage(
    actionButton("btnId", "I want a line break here <br/> since the label is too long")),
server = function(input, output){})

Best,
Weicheng

1 Like

I don't know if there is a solution to use a break wherever you want, but playing with css will do the job for sure.

library(shiny)
shinyApp(
  ui = fluidPage(
    actionButton("btnId", "I want a line break here<br/>since the label is too long",
                 style="white-space: normal;
                        text-align:center;
                        color: #fff; 
                        background-color:#CC3300;
                        border-color: #2e6da4;
                        height:50px;
                        width:150px;
                        font-size: 10px;")),
  server = function(input, output){})
1 Like

Thank you! It is a good solution by fixing the size of the button.
We'll see whether there are other solutions.
Thanks again for your help!

The following is another solution, credit goes to https://stackoverflow.com/a/46882196/2935353

library(shiny)
shinyApp(
      ui = fluidPage(
        actionButton("btnId", HTML("I want a line break here <br/> since the label is too long"))),
      server = function(input, output){})
3 Likes