如下圖所示,我試圖在使用popify()shinyBS 包中的函式呈現的資訊圖示前面放置一行文本。底部的代碼適用于資訊圖示前面沒有文本的情況,注釋掉是我插入文本的嘗試之一。取消注釋,運行代碼,你會看到亂碼輸出。
那么如何在圖示前面插入文本呢?一種選擇是將文本和圖示拆分為 2 個單獨的列,但我不想擺弄列寬以使其看起來正確。我希望文本“流入”圖示。
我認為這個 Stack Overflow 問題可能會提供答案,但它是一個死胡同:
代碼:
library(shiny)
library(shinyBS)
app = shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("bins","Number of bins:",min = 1,max = 50,value = 30)
),
mainPanel(
plotOutput("distPlot"),
uiOutput("uiExample")
)
)
),
server =
function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$uiExample <- renderUI({
# paste( #uncomment
# "Look at the little circle >>", #uncomment
tags$span(
popify(icon("info-circle", verify_fa = FALSE),
"Placeholder",
"This icon is <b>placeholder</b>. It will be fixed</em>!")
)
# ) #uncomment
})
}
)
runApp(app)
uj5u.com熱心網友回復:
這可以通過 atagList和 another來實作span:
library(shiny)
library(shinyBS)
app = shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("bins","Number of bins:",min = 1,max = 50,value = 30)
),
mainPanel(
plotOutput("distPlot"),
uiOutput("uiExample")
)
)
),
server =
function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$uiExample <- renderUI({
tagList(
tags$span(
"Look at the little circle >>"
),
tags$span(
popify(icon("info-circle", verify_fa = FALSE),
"Placeholder",
"This icon is <b>placeholder</b>. It will be fixed</em>!")
)
)
})
}
)
runApp(app)

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/520415.html
標籤:htmlr闪亮的闪亮的
上一篇:如何在圓形容器內居中引導圖示
