我有一台shiny 的showNotification,可以打印警告和错误.大多数情况下,它工作得很好,但有时会有很多警告或非常长的警告,用户不能全部看到.我怎样才能让showNotification垂直滚动?

以下是我的问题的再现.

library(shiny)


shinyApp(
  ui = fluidPage(
    actionButton("show", "Show")
  ),
  server = function(input, output) {
    observeEvent(input$show, {
      showNotification(
        "R version 4.3.0 (2023-04-21 ucrt) -- Already Tomorrow
        Copyright (C) 2023 The R Foundation for Statistical Computing
        Platform: x86_64-w64-mingw32/x64 (64-bit)

        R is free software and comes with ABSOLUTELY NO WARRANTY.
        You are welcome to redistribute it under certain conditions.
        Type 'license()' or 'licence()' for distribution details.

        R is a collaborative project with many contributors.
        Type 'contributors()' for more information and
        'citation()' on how to cite R or R packages in publications.

        Type 'demo()' for some demos, 'help()' for on-line help, or
        'help.start()' for an HTML browser interface to help.
        Type 'q()' to quit R.

        R version 4.3.0 (2023-04-21 ucrt) -- Already Tomorrow
        Copyright (C) 2023 The R Foundation for Statistical Computing
        Platform: x86_64-w64-mingw32/x64 (64-bit)

        R is free software and comes with ABSOLUTELY NO WARRANTY.
        You are welcome to redistribute it under certain conditions.
        Type 'license()' or 'licence()' for distribution details.

        R is a collaborative project with many contributors.
        Type 'contributors()' for more information and
        'citation()' on how to cite R or R packages in publications.

        Type 'demo()' for some demos, 'help()' for on-line help, or
        'help.start()' for an HTML browser interface to help.
        Type 'q()' to quit R.

        R version 4.3.0 (2023-04-21 ucrt) -- Already Tomorrow
        Copyright (C) 2023 The R Foundation for Statistical Computing
        Platform: x86_64-w64-mingw32/x64 (64-bit)

        R is free software and comes with ABSOLUTELY NO WARRANTY.
        You are welcome to redistribute it under certain conditions.
        Type 'license()' or 'licence()' for distribution details.

        R is a collaborative project with many contributors.
        Type 'contributors()' for more information and
        'citation()' on how to cite R or R packages in publications.

        Type 'demo()' for some demos, 'help()' for on-line help, or
        'help.start()' for an HTML browser interface to help.
        Type 'q()' to quit R.

        R version 4.3.0 (2023-04-21 ucrt) -- Already Tomorrow
        Copyright (C) 2023 The R Foundation for Statistical Computing
        Platform: x86_64-w64-mingw32/x64 (64-bit)

        R is free software and comes with ABSOLUTELY NO WARRANTY.
        You are welcome to redistribute it under certain conditions.
        Type 'license()' or 'licence()' for distribution details.

        R is a collaborative project with many contributors.
        Type 'contributors()' for more information and
        'citation()' on how to cite R or R packages in publications.

        Type 'demo()' for some demos, 'help()' for on-line help, or
        'help.start()' for an HTML browser interface to help.
        Type 'q()' to quit R.

        R version 4.3.0 (2023-04-21 ucrt) -- Already Tomorrow
        Copyright (C) 2023 The R Foundation for Statistical Computing
        Platform: x86_64-w64-mingw32/x64 (64-bit)

        R is free software and comes with ABSOLUTELY NO WARRANTY.
        You are welcome to redistribute it under certain conditions.
        Type 'license()' or 'licence()' for distribution details.

        R is a collaborative project with many contributors.
        Type 'contributors()' for more information and
        'citation()' on how to cite R or R packages in publications.

        Type 'demo()' for some demos, 'help()' for on-line help, or
        'help.start()' for an HTML browser interface to help.
        Type 'q()' to quit R."
      )
    })
  }
)

推荐答案

您可以在您的ui中添加一些css,以设置 Select 器.shiny-notification的样式.这里的关键是定义overflow: auto;以使其可滚动.

    ui = fluidPage(actionButton("show", "Show"),
                   tags$head(tags$style(
                       HTML(
                           ".shiny-notification {
                                position:fixed;
                                top: 10px;
                                bottom: 0px;
                                left: 300px;
                                right: 300px;
                                overflow: auto;
                            }
                           "
                       )
                   ))),

enter image description here

Css相关问答推荐

Angular Material:如何同时使用2个徽章

如何引用 SCSS 中的现有类?

有没有办法在 CSS 字体速记中使用数字字体粗细?

在具有特定类的 td 之后,如何编写适用于该行上所有 td 元素的表行的 CSS Select 器?

用户代理必须处理(或表现得好像他们这样做)每个链接就好像链接指向单独的样式表这句话是什么意思?

最多 2 行的 Flex 水平滚动

在 WooCommerce 变体 Select 中转换属性文本以大写

父母是内联块,子元素有%填充=奇怪的行为

flex 容器中的两个滚动块

CSS动画移动divs upwords

为什么 flexbox 中的 在应用居中时不会调整大小?

在表格中隐藏绝对伪元素

找到第一个可滚动的父级

svg 背景图像位置始终在 Internet Explorer 中居中,尽管 background-position: left center;

我应该使用 CSS :disabled 伪类还是 [disabled] 属性 Select 器,还是见仁见智?

纯 CSS 滚动动画

如何在没有填充区域的情况下背景化 div

从 css 添加标题属性

矩形图像的 CSS 圆形裁剪

CSS关键帧动画CPU占用率高,应该这样吗?