首页 > 解决方案 > 如何为 R shinyWidgets > prettyToggle > label_on(和 label_off)换行文本

问题描述

函数“label_on”(shinyWidgets > prettyToggle)的文本太长,超出了框框。如何包装文本并留在框内?

我在这里发现了类似的问题,但对于 pickerInput (如何从 pickerInput 中对选择进行文本换行,如果选择的长度很长,则选择通常会出现在屏幕之外)。

我还添加了 (tags$style(HTML('.pretty .state label { white-space: normal; word-break: keep-all; }')) ,但它使图标偏移。

library(shiny); library(shinydashboard); library(shinyWidgets)

ui <- dashboardPage(
dashboardHeader(title = "THE RAFT"),
dashboardSidebar(sidebarMenu(menuItem("Introduction", tabName = "intro", icon = icon("dashboard")))),
dashboardBody(

  # run this command line to wrap text but as a result icon is off set
  # tags$style(HTML('.pretty .state label { white-space: normal; word-break: keep-all; }')),

  tabItems(tabItem(tabName = "intro", box(title = "Box 1",
                prettyToggle(inputId = "inp001", icon_on = icon("thumbs-up"), icon_off = icon("thumbs-down"),
                             outline = TRUE, plain = TRUE, animation = "rotate",
                             label_off = "Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.",
                             label_on = "Short"
))))))

server <- function(input, output) { }
shinyApp(ui, server)

标签: r

解决方案


推荐阅读