Skip to content

How to apply Multi-Column Alignment? #755

@msgoussi

Description

@msgoussi
library("shiny")
library("shinyWidgets")

ui <- fluidPage(
  # checkboxGroupButtons(
  #   inputId = "somevalue",
  #   choices = c("A", "B", "C"),
  #   label = "My label"
  # ),
  # Custom CSS to ensure vertical alignment of checkbox and its label
  prettyCheckboxGroup("somevalue", "Variables to show:",
                     c("Cylinders" = "A",
                       "text" = "A", 
                       "Transmission" = "B",
                       "Gears" = "C",
                       "Cylinders" = "A",
                       "text" = "A", 
                       "Transmission" = "B",
                       "Gears" = "C",
                       "text" = "A", 
                       "Transmission" = "B",
                       "Gears" = "C"
                       ),

                     status = "primary", # "info" provides a blue color
                     animation = "pulse", # Optional: Adds a pulse animation
                     icon = icon("check"),  # Specifies the Font Awesome check icon 
                     inline = TRUE
                     )
  , 
  
  verbatimTextOutput(outputId = "res"),
  
  virtualSelectInput(
    inputId = "updateselected",
    label = "Update selected:",
    choices = c("A", "B", "C"),
    multiple = TRUE,
    
  ),
  actionButton(inputId = "clear", label = "Clear selected")
)

server <- function(input, output, session) {
  
  output$res <- renderPrint({
    input$somevalue
  })
  observe({
  x <- input$updateselected
  
  # Can use character(0) to remove all choices
  if (is.null(x))
    x <- character(0)
  
  updatePrettyCheckboxGroup(
      session = session,
      inputId = "somevalue",
      selected = x
    )
  })
    
}

if (interactive())
  shinyApp(ui = ui, server = server)

I am wondering if i could have 5 columns alignment not missy like below

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions