Calosoma
Calosoma

Reputation: 71

Prevent textOutput from producing line break

I build an application with shinydashboard and try to produce a box with (reactive) text. My code in dashboardBody is

box("Species was found in ", textOutput("Count1"), "of", Count2, "Sites")

Count1 is reactive and based on User Input in the UI. Count2 is defined in global.R.

The Output is:

Species was found in
1
of 134 Sites

So, how do I remove the line breaks? paste() isn't working since it only shows the html code of the textoutput Element.

Upvotes: 3

Views: 837

Answers (2)

ek-g
ek-g

Reputation: 721

Based on the comments it did work, so here my solution as an answer:

box("Species was found in ", textOutput("Count1", inline = TRUE), "of", Count2, "Sites")

Without inline = TRUE it puts the textOuput()in a div, so that creates the line breaks.

Upvotes: 2

Pork Chop
Pork Chop

Reputation: 29387

Wrapping every element should work:

box(
    div(style="display: inline-block;","Species was found in "), 
    div(style="display: inline-block;",textOutput("Count1")), 
    div(style="display: inline-block;",paste("of", Count2, "Sites"))
)

enter image description here

Upvotes: 1

Related Questions