My interactive checkboxGroupInput
is designed to display the column names from a user-provided input file. Sometimes, this input file contains over one hundred columns. To address this, I followed this answer to organize the choices into multiple columns. While this solution works well most of the time, it encounters issues when handling very large column names that cause the labels to extend beyond the box:
https://i.sstatic.net/yDuu9.jpg
Do you have any suggestions on how to resolve this problem?
To illustrate the scenario, I have created a sample code using the mtcars
dataset (using row.names
instead of colnames
for illustrative purposes).
library(shiny)
library(shinydashboard)
sidebar <- dashboardSidebar(
sidebarMenu(
busyIndicator(text="Loading..."),
tags$head(
tags$style(
HTML('
.multicol {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
column-count: 3;
-moz-column-fill: auto;
-column-fill: auto;
}
')
)
),
menuItem("Plot result", tabName = "scatterplot", icon = icon("area-chart"))
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "scatterplot",
box(
title="CHECKBOX",solidHeader = TRUE, status="primary",
tags$div(align = 'left',
class = 'multicol', uiOutput("covarselect")),
width=2
)
)
)
)
ui=dashboardPage(
dashboardHeader(title = "analysis"),
sidebar,
body
)
server <- function(input, output,session) {
output$covarselect <- renderUI({
mtcars <- datasets::mtcars
row.names(mtcars) <- gsub(" ","",row.names(mtcars))
checkboxGroupInput("carselect","Select any that apply",as.list(row.names(mtcars)),inline=F)
})
}
shinyApp(ui = ui, server = server)
EDIT
Upon Nikhil Nanjappa's suggestion, I attempted to recreate the issue in a fiddle, but was unable to replicate the box
as seen in shinydashboard