nm200
nm200

Reputation: 336

Shiny: stop word splitting in VerbatimTextOutput

I am trying to create a Shiny app with some text boxes. I like that the verbatimTextOutput has a box around the text, but with slightly longer text, the words get broken in meaningless places in order to wrap the text. Is there some way that I can stop the words from being split? A very simple example is below.

ui <- fluidPage(
  fluidRow(column(3, offset=0, verbatimTextOutput("TxtOut")))
)

server <- function(input, output, session) {
  output$TxtOut <- renderText(
    "a longish text that goes over multiple lines and breaks words"
  )
}

shinyApp(ui = ui, server = server)

Upvotes: 1

Views: 1112

Answers (1)

Sagar
Sagar

Reputation: 2934

Because column width is set to 3, your text is wrapping in the output function. As explained in the comments above, following style will prevent wrapping, and add a scroll bar to navigate.

ui <- fluidPage(
  tags$head(tags$style("#TxtOut {white-space: nowrap;}")),
  fluidRow(column(3, offset=0, verbatimTextOutput("TxtOut")))
)

Upvotes: 2

Related Questions