I am building an R Shiny application where I use the pickerInput()
function (from the shinyWidgets
package) to allow users to select columns from a dataset. However, if the column names are longer than 20 characters, they are truncated with ellipses (...
). Here’s a simplified example of my code:
library(shiny)
col_names <- c("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"cccccccccccccccccccccccccccccccccccc")
ui <- fluidPage(
shinyWidgets::pickerInput(
"all_cols_id",
NULL,
choices = col_names,
selected = NULL,
options = shinyWidgets::pickerOptions(
actionsBox = TRUE,
size = 10,
selectedTextFormat = "count > 0"
),
multiple = TRUE,
choicesOpt = list(
content = stringr::str_trunc(col_names, width = 22)
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
Currently, the dropdown items display truncated column names. I want to add a hover feature where the full column name appears as a tooltip when the user hovers over a dropdown item.
How can I implement this feature in the pickerInput
dropdown?
2