R闪亮小部件:将actionbttn格式设置为与downloadbttn相同

问题描述 投票:0回答:1

我想格式化我的actionbttn小部件,使其图标在文本上方居中对齐,就像downloadbttn小部件(见图),但似乎没有简单的方法可以在没有css/html的情况下完成此操作。

下面提供了我用于生成示例的代码。

library(shiny)
library(shinydashboard)
library(shinyWidgets)

# Define UI for application that draws a histogram
ui <- dashboardPage(

    # Application title
    dashboardHeader(title = "Old Faithful Geyser Data"),

    # Sidebar with a slider input for number of bins 
    dashboardSidebar(
      menuItem(
        "Results", 
        icon = icon("table"),
        downloadBttn(
          outputId = "saveplot",
          label = "Save plot",
          style = "simple",
          size = "sm"
        ),
        actionBttn(
          inputId = "deleteLocalSave", 
          label = "Reset settings", 
          style="simple", 
          size = "sm",
          color = "danger",
          icon = icon("trash")
        ),
        br(),
        expandedName = "exp_results"
      )
    ),
    
    dashboardBody(
      
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

}

# Run the application 
shinyApp(ui = ui, server = server)
r shiny shinywidgets
1个回答
0
投票

你是对的,没有 CSS 或 HTML 就没有办法做到这一点,但只需使用

HMTL()
并在标题上添加一个段落即可完成:


library(shiny)
library(shinydashboard)
library(shinyWidgets)

# Define UI for application that draws a histogram
ui <- dashboardPage(
  # Application title
  dashboardHeader(title = "Old Faithful Geyser Data"),
  
  # Sidebar with a slider input for number of bins
  dashboardSidebar(
    menuItem(
      "Results",
      icon = icon("table"),
      downloadBttn(
        outputId = "saveplot",
        label = "Save plot",
        style = "simple",
        size = "sm"
      ),
      actionBttn(
        inputId = "deleteLocalSave",
        label = HTML("<p>Reset settings"),
        style = "simple",
        size = "sm",
        color = "danger",
        icon = icon("trash")
      ),
      br(),
      expandedName = "exp_results"
    )
  ),
  
  dashboardBody()
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  
}

# Run the application
shinyApp(ui = ui, server = server)

© www.soinside.com 2019 - 2024. All rights reserved.