Adding/removing downloadButton() 和 fileInput() 中的图标
Adding/removing icon in downloadButton() and fileInput()
在 Shiny 中,我们有 downloadButton()
和 fileInput()
按钮分别用于下载和上传数据。
然而,downloadButton()
有 下载 图标,而 fileInput()
没有附加图标。
在我的 Shiny 应用程序中,我有两个按钮。但是,由于其中一个附加了图标,它给我的应用程序带来了某种视觉上的不一致。
所以,我要么想从 downloadButton()
中删除这样的图标,要么添加一些 上传 按钮和 fileInput()
以保持一致性。
但是,似乎没有任何直接的方法来执行它们中的任何一个。
如果有任何方法,有人可以在这里提出建议吗:
从 downloadButton()
中删除图标,或者附加一些 上传
带有 fileInput()
的图标
非常感谢任何指点。
谢谢,
如果您查看 downloadButton
的源代码,您会发现 changing/removing 按钮非常简单
downloadButton
## function (outputId, label = "Download", class = NULL, ...)
## {
## aTag <- tags$a(id = outputId, class = paste("btn btn-default shiny-download-link",
## class), href = "", target = "_blank", download = NA,
## icon("download"), label, ...)
## }
## <environment: namespace:shiny>
您只需将 icon("download")
替换为 NULL
。这是一个完整的例子
myDownloadButton <- function(outputId, label = "Download"){
tags$a(id = outputId, class = "btn btn-default shiny-download-link", href = "",
target = "_blank", download = NA, NULL, label)
}
shinyApp(
fluidPage(myDownloadButton("download")),
function(input, output, session){
output$download = downloadHandler(
"file.rds", function(file){ saveRDS(mtcars, file) }
)
}
)
要将图标添加到 fileInput(),请将列表添加到 buttonLabel。例如
shinyApp(
fluidPage(
fileInput("myFileInput",label="Test",buttonLabel=list(icon("folder"),"TestyMcTestFace"))
),
function(input, output, session){
}
)
在 Shiny 中,我们有 downloadButton()
和 fileInput()
按钮分别用于下载和上传数据。
然而,downloadButton()
有 下载 图标,而 fileInput()
没有附加图标。
在我的 Shiny 应用程序中,我有两个按钮。但是,由于其中一个附加了图标,它给我的应用程序带来了某种视觉上的不一致。
所以,我要么想从 downloadButton()
中删除这样的图标,要么添加一些 上传 按钮和 fileInput()
以保持一致性。
但是,似乎没有任何直接的方法来执行它们中的任何一个。
如果有任何方法,有人可以在这里提出建议吗:
从 downloadButton()
中删除图标,或者附加一些 上传
带有 fileInput()
非常感谢任何指点。
谢谢,
如果您查看 downloadButton
的源代码,您会发现 changing/removing 按钮非常简单
downloadButton
## function (outputId, label = "Download", class = NULL, ...)
## {
## aTag <- tags$a(id = outputId, class = paste("btn btn-default shiny-download-link",
## class), href = "", target = "_blank", download = NA,
## icon("download"), label, ...)
## }
## <environment: namespace:shiny>
您只需将 icon("download")
替换为 NULL
。这是一个完整的例子
myDownloadButton <- function(outputId, label = "Download"){
tags$a(id = outputId, class = "btn btn-default shiny-download-link", href = "",
target = "_blank", download = NA, NULL, label)
}
shinyApp(
fluidPage(myDownloadButton("download")),
function(input, output, session){
output$download = downloadHandler(
"file.rds", function(file){ saveRDS(mtcars, file) }
)
}
)
要将图标添加到 fileInput(),请将列表添加到 buttonLabel。例如
shinyApp(
fluidPage(
fileInput("myFileInput",label="Test",buttonLabel=list(icon("folder"),"TestyMcTestFace"))
),
function(input, output, session){
}
)