Érico Patto
Érico Patto

Reputation: 1015

Space added inside text in UI part of Shiny

I've noticed that a space appears when I use em(), strong() and, apparently, textOutput() when they're inside a p() tag in the ui, or even if they're loose text. This is my code:

ui <- fluidPage(
  p("This is ", strong("bold"), ", and this is ", em("italic"), "."),
  br(),
  "Again, this is ", strong("bold"), ", and this is ", em("italic"), "."
)

There isn't anything on the server. The textOutput() example is a little longer, and it doesn't show anything new, so I left it out.

The output is this:

This is bold , and this is italic .

Again, this is bold , and this is italic .

As you can see, the comma and the period are separated by a space. This is really annoying – after all, punctuation marks don't have this in "proper" English, which is something I'd like to preserve in my Shiny App.

Upvotes: 1

Views: 686

Answers (1)

polkas
polkas

Reputation: 4194

You could use .noWS parameter.

library(shiny)

ui <- fluidPage(
  p("This is ", strong("bold", .noWS = c("after")), ", and this is ", em("italic"), "."),
  br(),
  "Again, this is ", strong("bold", .noWS = c("after")), ", and this is ", em("italic"), "."
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Result:

This is bold, and this is italic .

Again, this is bold, and this is italic .

Upvotes: 2

Related Questions