Shiny: stop word splitting in VerbatimTextOutput

2019-07-31 17:13发布

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)

标签: r textbox shiny
1条回答
We Are One
2楼-- · 2019-07-31 17:42

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")))
)
查看更多
登录 后发表回答