Reputation: 865
I am trying to align the label and radio button in the same line in the application but I'm unable to achieve that.
This is the code used for displaying the label and radio button
fluidRow(
align = 'center',
column(5,"Choose Metric: "),
column(11, radioButtons("typeRadio", "",list("Project Count", "Project Efforts"), inline = TRUE))
)
But I'm getting this output
How can I get the label and radioButton in the same line?
Can anyone provide a proper solution to achieve the expected output?
Upvotes: 4
Views: 1303
Reputation: 12461
It's very hacky, but this works for me:
library(shiny)
ui <- fluidPage(
fluidRow(
align="center",
column(2, "Choose Metric: "),
column(4, radioButtons("typeRadio", "",list("Project Count", "Project Efforts"), inline = TRUE))
)
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
Your original code defines 16 colulmns. That will cause problems for any solution: the maximum column count is 12.
My solution works because specifying label=""
causes Shiny to output the HTML for a label, which is invisible (because it's the empty string), but which still occupies vertical space. Specifying label=NULL
suppresses all output associated with the label, and hence it occupies no vertical space.
Put another way, your solution does align the tops of the two widgets. It's just that the top of the radio group is invisible.
Incidentally, it's always best to provide a simple, self-contained example, even for a set up as obvious as this.
Upvotes: 2