Art*_*rra 4 r shiny flexdashboard
我在更改 DownloadButton 宽度时遇到问题,因为他与 actionButton (具有宽度参数)不同。
有什么简单的想法可以解决吗?这是我的代码(只是一个简单的下载按钮):
Normalidade
=======================================================================
Inputs {.sidebar}
-----------------------------------------------------------------------
<h5>
```{r}
tags$hr()
downloadButton("downloadNormal",label = "Download seu teste", class = "butt1")
downloadHandler(
filename = "Resultados_Normal.csv",
content = function(file) {
write.csv(data, file)
}
)
tags$hr()
tags$br()
actionButton("AjudaNormal", label = " Ajuda", icon("question-circle"),
width = "100%",
onclick="window.open('http://google.com', '_blank')")
```
</h5>
Run Code Online (Sandbox Code Playgroud)
实际上,在尝试过这个之后,我建议使用uiOutputwith renderUI。
如果不使用uiOutput该downloadButton函数,则会被忽略(仅downloadHandler会评估该函数),这就是width未设置参数的原因,并且您也无法修改按钮的标签。
使用 就全部解决了uiOutput。
---
title: "Full width downloadButton"
output:
flexdashboard::flex_dashboard:
css: styles.css
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
```
Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
# Create placeholder for the downloadButton
uiOutput("downloadUI")
```
```{r}
# Create the actual downloadButton
output$downloadUI <- renderUI( {
downloadButton("downBtn", "Download Iris data", style = "width:100%;")
})
# Add download handling
output$downBtn <- downloadHandler(
filename = function() {
"iris.csv"
},
content = function(file) {
write.csv(iris, file, row.names = FALSE)
}
)
```
Run Code Online (Sandbox Code Playgroud)
我使用参数设置了widthusing inlineCSSstyle,但是如果您有多个 CSS 规则,您可以(并且应该)使用外部样式表。
css: path/filename.css通过添加到 YAML 标头,可以在 Flexdashboard 中使用外部 CSS 文件。
---
title: "Full width downloadButton"
output:
flexdashboard::flex_dashboard:
css: styles.css
runtime: shiny
---
Run Code Online (Sandbox Code Playgroud)
在这种情况下,应用程序尝试读取styles.css与Rmd.
在同一文件夹中创建 css 文件并添加规则:
#downBtn {
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
您现在可以style = "width:100%;"从 中删除downloadButton并仍然获得全宽按钮。