Cómo poner radioGroupButtons brillantes en columnas

Nov 29 2020

Me gustaría alinear algunos radioGroupButtons()de shinyWidgetsen 5 columnas igualmente espaciadas. También me gustaría que todos los botones tuvieran el mismo ancho. Los anchos de columna funcionan un poco mejor si lo uso, direction = "vertical"pero las columnas terminan aún más alejadas entre sí. Así es como se ve como está.

Tal vez la respuesta esté oculta aquí, pero no pude entenderla.

library(shiny)
library(shinyWidgets)

my_css <-
  ".btn-group, .btn-group-vertical {
    column-count: 5;
  }"


ui <- 
  fluidPage(
    tags$head(tags$style(HTML(my_css))),
    radioGroupButtons(
      inputId = "somevalue1",
      label = NULL,
      choices = 
        setNames(
          1:20,
          rep(c("xs", "medium", "very long", "a whole lotta text"), 5)
        )#, direction = "vertical"
    )
  )


server <- function(input, output) {}

shinyApp(ui, server)

Respuestas

2 gdevaux Nov 29 2020 at 17:35

Puedes tener todo con el mismo ancho jugando con el CSS de la clase btn-group-toggle y radiobtn.

my_css <-
  ".btn-group, .btn-group-vertical {
    column-count: 5;
  }
  
  .btn-group-toggle {
  width:200px;
  }

  .radiobtn { 
    width:200px;
  }"