如何右对齐 selectInput 标签上的 actionLink 标签

Posted

技术标签:

【中文标题】如何右对齐 selectInput 标签上的 actionLink 标签【英文标题】:How to right align label of actionLink which on label of selectInput 【发布时间】:2020-03-03 06:47:54 【问题描述】:

[上一个问题]How to include an action link into a button's label?

如何在 sidbarPanel 右侧对齐“获取帮助”?

library(shiny)

ui <- fluidPage(
  br(),
  selectInput(
    inputId = "some_id", 
    label = html("Please choose A or B", 
                 as.character(actionLink(inputId = 'action_link', label = 'get help'))),
    choices = c("choice A", "choice B"),
    selected = "choice A",
    selectize = F
  )
)


server <- function(input, output) 

shinyApp(ui, server)

【问题讨论】:

【参考方案1】:

据我所知,您希望在选择输入的一侧有一个帮助图标或链接。 您可以使用 shinyhelper 库。有关详细文档,您可以参考here

我尝试了一个示例来使用它:希望对您有所帮助

library(shiny)
library(shinyhelper)
library(magrittr)

ui <- fluidPage(

  titlePanel(title = "Demo APP"),

  sidebarLayout(

    sidebarPanel = sidebarPanel(

      selectInput(inputId = "dataset", "choose DataSet",
                  choices = c("MTCARS","IRSIS")
      ) %>% 
        helper(type = "inline",
               title = "Inline Help",
               content = c("This helpfile is defined entirely in the UI!",
                           "This is on a new line.",
                           "This is some <b>HTML</b>."),
               size = "s")
    ),

    mainPanel = mainPanel(
      verbatimTextOutput(outputId = "TABLE")

    )
  )
)


server <- function(input, output) 
  observe_helpers()
  output$TABLE<-renderText(

    paste0("Dataset selcted: ",input$dataset)

  ) 


shinyApp(ui, server)

输出看起来像:

点击图标后:

【讨论】:

以上是关于如何右对齐 selectInput 标签上的 actionLink 标签的主要内容,如果未能解决你的问题,请参考以下文章

如何对齐闪亮的输入框,特别是 selectInput 和 numericInput

HTML span标签如何居中和右对齐?这里有HTML span标签的样式解析

R Shiny - 如何在 selectInput 中显示选择标签

java 怎么把图形标签左对齐?

form中label标签对齐,内容右对齐

如何让 WPF DataGrid 单元格右对齐而不使新行上的可选区域变小?