mercredi 3 juillet 2019

Left align checkboxgroups to a single column in a shiny sidebar

New to R/Shiny, I'm attempting to create checkboxgroups in a Shiny sidebar where choices are in a single column and left aligned.

Additionally, is there any way to remove the break/space between the first and second checkboxinputs?

I've tried turning "inline" on and off, but it doesn't seem related. From what I can see in the forums, the answer might require HTML/CSS, but I'm not sure how to integrate that into a sidebar/checkbox group.

Here's how the code looks currently:

library(shiny)
library(shinydashboard)

sidebar <- dashboardSidebar(
    checkboxGroupInput( inputId='ABC', label='ABC', choices= c('A','B','C'), inline=TRUE )
    ,checkboxInput('bar0','All/None', value=TRUE))

header <- header <- dashboardHeader(
  title = "aligned column",titleWidth = 300)

body <- dashboardBody()

ui <- dashboardPage(title = 'aligned column', header, sidebar, body)

server <- function(input, output,session) { 
  ## All/None buttons on selections ----
  observeEvent( input$bar0, {
    updateCheckboxGroupInput(
      session, 'ABC', choices = c('A','B','C'), inline=TRUE,
      selected = if (input$bar0) choices = c('A','B','C'))})
}

shinyApp(ui, server)

Thanks!




Aucun commentaire:

Enregistrer un commentaire