Search code examples
rshinyradio-buttonlabel

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

Solution

  • 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