[英]How can I create a title for my verbatimTextOutput on my RShiny dashboard?
I plan to have several verbatimTextOutputs on my RShiny dashboard.我计划在我的 RShiny 仪表板上有几个逐字文本输出。 Therefore, to help the user, I'd like to make them distinctive by adding titles/names above them.
因此,为了帮助用户,我想通过在它们上方添加标题/名称来使它们与众不同。
However, verbatimTextOutputs has no such argument, so I had a look at CSS styling which I am not particularly familiar with, so here I might have a mistake but it seemed to me I can't add a title to my object using CSS.但是,verbatimTextOutputs 没有这样的论点,所以我查看了 CSS 样式,我不是特别熟悉,所以在这里我可能有一个错误,但在我看来,我无法使用 Z2C56C36058042 为我的 object 添加标题。 I can do a whole bunch of other fancy stuff such as font types, colors, etc. though but that doesn't really solve my issue.
我可以做一大堆其他花哨的东西,比如字体类型、colors 等,但这并不能真正解决我的问题。 Then I read I might need to tinker with JavaScript to add those titles above my outputs.
然后我读到我可能需要修改 JavaScript 以在我的输出上方添加这些标题。
library(shiny)
ui <- fluidPage(
actionButton("btn", "Press me"),
verbatimTextOutput("dem"),
tags$head(tags$style(HTML("
#dem {
title: somefancyname;
width: 100px;
height: 45px;
position: relative;
}
")))
)
server <- function(input, output, session) {
observeEvent(input$btn, {
output$dem <- renderText(1)
})
}
shinyApp(ui, server)
Am I on the right track?我在正确的轨道上吗? Can someone please help me out whether what I'm trying to achieve is feasible and what should I do here?
有人可以帮我弄清楚我想要实现的目标是否可行,我应该在这里做什么? Thank you in advance.
先感谢您。
You don't need the style tag, just add the title with an h2
or other heading tag... see ?tags
您不需要样式标签,只需添加带有
h2
或其他标题标签的标题...参见?tags
library(shiny)
ui <- fluidPage(
actionButton("btn", "Press me"),
tags$h2("Dem output"), ### Add one of these above any and all of your outputs...
verbatimTextOutput("dem"),
tags$head(tags$style(HTML("
#dem {
title: somefancyname;
width: 100px;
height: 45px;
position: relative;
}
")))
)
server <- function(input, output, session) {
observeEvent(input$btn, {
output$dem <- renderText(1)
})
}
shinyApp(ui, server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.