maximus
maximus

Reputation: 174

Display the label AND choices on same line in Shiny radioButtons

I would like both the label AND the choices to be displayed on the same line in radioButtons in Shiny.

I have tried:

tags$div(tags$span(radioButtons("id",label = "Label:",choices = c("All "="all","Option One"="option1","Option Two"="option2"),inline=TRUE)))

with and without the "tags$div(tags$span(" piece.

I would like the result to be:

Label: ()All ()Option One () Option two

Instead, i am still getting

 Label:
 ()All ()Option One () Option two

Upvotes: 5

Views: 1692

Answers (2)

MKa
MKa

Reputation: 2318

Try float: left

So it will be something like:

library(shiny)

ui <- fluidPage(
  tags$head(
    tags$style(
      HTML(
        "
        label{
          float:left;
        }
      "
      ))),

      radioButtons("id1",label = "Label:",choices = c("All "="all","Option One"="option1","Option Two"="option2"),inline=TRUE)

)

server <- function(input, output) {

}

shinyApp(ui, server)

enter image description here

Upvotes: 5

Ben
Ben

Reputation: 1144

Would a new variable with concatenated information work?

Something like:

 df$labelNew<-paste(df$var,"",df$choices)

Upvotes: 0

Related Questions