Reputation: 79
I created a UI page with some buttons and have two problems with the checkboxInput buttons:
checkboxInput('comissions', label = "Comissions", width = "10%")
Changing the width = "X%" doesn't change anything, same for 'Xpx'. I suspected this is due to fixed column width, but the X% change works for other buttons well.
Second issue is that the button looks like this:
I would like it to be centered and not be in left column.
Thank you for the help,
Upvotes: 3
Views: 1457
Reputation: 84529
Here is a way to center the checkbox, but it requires width = "100%"
.
library(shiny)
ui <- basicPage(
fluidRow(
column(4,
sliderInput("costs", "Costs", min = 1, max = 10, value = 1)),
column(4, style = "text-align: center;",
checkboxInput("comissions", label = "Comissions", width = "100%")),
column(4,
sliderInput("periods", "Number of periods", min = 1, max = 10, value = 1))
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
I don't know what you expect to see by changing the width ?
To control the white space around the checkbox input, and its vertical alignment:
library(shiny)
ui <- basicPage(
fluidRow(
column(12,
div(style = "display: inline-block;",
sliderInput("costs", "Costs", min = 1, max = 10, value = 1)
),
div(style = "display: inline-block; margin-left: 20px; margin-right: 20px; vertical-align: -20px;",
checkboxInput("comissions", label = "Comissions", width = "100%")
),
div(style = "display: inline-block;",
sliderInput("periods", "Number of periods", min = 1, max = 10, value = 1)
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
Upvotes: 5