R-SHININY-如何在Well Panel中将按钮/图标排成一行? [英] R - Shiny - How to align buttons/icons in a single row in wellpanel?
本文介绍了R-SHININY-如何在Well Panel中将按钮/图标排成一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已在Well Panel中放置了3个按钮图标。
问题是所有3个图标没有出现在同一行中(";屏幕截图&图标出现在第一行,下两个图标出现在第二行)。
我尝试与";fiedRow";和";style";对齐,但无法实现。
有人能帮我做这件事吗?
谢谢...
脚本:
TableA = data.frame(Product = c('iPhone', 'Macbook', 'Airpod', 'Macbook', 'Airpod', 'Macbook', 'iPhone'), East = c(1:7), West = c(5:11), North = c(15:21), South = c(24:30))
library(shiny)
library(shinythemes)
library(DT)
library(rhandsontable)
library(tidyverse)
library(tidyquant)
library(knitr)
library(gt)
library(shinycssloaders)
library(shinydashboard)
library(shinyWidgets)
header = dashboardHeader(title = 'Shiny Dashboard', titleWidth = 400)
sidebar = dashboardSidebar(
wellPanel(
"Export Options", id = "DownloadPanel", style = "background: #222d32; max-height: 145px; max-width: 220px; align-items: center",
fixedRow(tags$div(style="display: inline-block; vertical-align:center; horizontal-align:center", class = "row-fluid",
screenshotButton(selector="#TableC", label = NULL, filename = paste("Summary")),
downloadButton(outputId = "SummaryExcelDownload", label = NULL, icon = icon("file-excel"), class = "butt1",
tags$head(tags$style(".butt{background-color:white;} .butt1{color: #217346 !important;}"))),
downloadButton(outputId = "SummaryPdfDownload", label = NULL, icon = icon("file-pdf"), class = "butt2",
tags$head(tags$style(".butt{background-color:white;} .butt2{color: #b30c00 !important;}")))
))
)
)
body <- dashboardBody(uiOutput("mainpanel"))
ui = dashboardPage(header, sidebar, body)
############
server = function(input, output, session)
{
output$mainpanel = renderUI({
fluidRow(tabBox(width = 250, height = 100,
tabPanel("Apple Sales", value = 'tab1', gt_output(outputId = "TableC")%>% withSpinner(color="#3483CA", type = 1, size = 2))
))
})
TableB = as.data.frame(TableA) %>%
gt() %>%
grand_summary_rows(columns = 2:5, fns = list(TotalSales = "sum")) %>%
tab_options(grand_summary_row.background.color = "#DDEBF7") %>%
cols_width(columns = 1 ~ px(1), columns = 2 ~ px(300), everything() ~ px(100)) %>%
tab_spanner(label = "Sales", columns = 3:6)
output$TableC = render_gt(expr = TableB)
output$SummaryExcelDownload = downloadHandler(
filename = "Summary.pdf",
content = function(file) {write.xlsx(TableC, file)})
output$SummaryPdfDownload = downloadHandler(
filename = "Summary.pdf",
content = function(file) {write.xlsx(TableC, file)})
}
############
shinyApp(ui = ui, server = server)
输出:
注意: 请忽略Excel和pdf下载(输出$SummaryExcelDownload和输出$SummaryPdfDownload)的";服务器&q;参数,因为我仍在尝试更正它们。
推荐答案
试试
library(shinyscreenshot)
header = dashboardHeader(title = 'Shiny Dashboard', titleWidth = 400)
sidebar = dashboardSidebar( width=300,
h5(strong("If you want to see buttons in a row, just use div()")),
fluidRow(div(
div(style="display: inline-block; width: 135px ;", screenshotButton("btn21", "Buttons")),
div(style="display: inline-block; width: 75px ;", downloadButton("btn22", "in a")),
div(style="display: inline-block; width: 75px ;", downloadButton("btn23", "row"))
)),
div(style="display: inline-block; vertical-align:center; horizontal-align:center", class = "row-fluid",
actionButton("btn11", "Buttons"),
actionButton("btn12", "in a"),
actionButton("btn13", "col")
),
div(
div(style="display: inline-block; width: 95px ;", actionButton("btn31", "Buttons")),
div(style="display: inline-block; width: 75px ;", actionButton("btn32", "in a")),
div(style="display: inline-block; width: 65px ;", actionButton("btn33", "row"))
)
)
body <- dashboardBody()
ui = dashboardPage(header, sidebar, body)
server <- function(input, output) {}
shinyApp(ui, server)
这篇关于R-SHININY-如何在Well Panel中将按钮/图标排成一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文