Ciaran O Brien
Ciaran O Brien

Reputation: 384

RShiny static text and textOutput on the same line

I've put together a simple RShiny app related to finance and trading. https://obrienciaran.shinyapps.io/cfd_new_value/

This is likely a very basic question, but right now in the side bar you can see text that says 'Current margin:' with a percent under it. Obtained via:

  tags$b("Current margin:"),
    h5(textOutput("current_margin"))

I just want these outputs side by side so it is displayed as

'Current margin: x%'

and not

'Current Margin:'

'x%'

Upvotes: 0

Views: 881

Answers (1)

gdevaux
gdevaux

Reputation: 2505

Use the argument inline=TRUE and put the text "Current margin" and the output in the same div, here it is h5.

library(shiny)

ui <- 
  fluidPage(
    h5(tags$b("Current margin:"),textOutput("current_margin", inline = TRUE))
)


server <- function(input, output, session) {
  output$current_margin <- renderText({
    "10%"
  })
}

shinyApp(ui, server)

Upvotes: 2

Related Questions