将 shinyhelper 图标移近标签
Move shinyhelper icon closer to label
如何移动 shinyhelper 图标“?”,使其恰好位于“Province”一词的右侧?
R 脚本
library(shiny)
library(magrittr)
library(shinyhelper)
library("bslib")
select_input_width <- "270px"
provinces <- c("British Columbia", "Alberta", "Saskatchewan", "Manitoba", "Ontario", "Quebec",
"New Brunswick", "Nova Scotia", "PEI", "Newfoundland and Labrador")
ui <- bootstrapPage(
theme = bs_theme(version = 5,
"font-scale" = 1.0),
div(class = "container-fluid",
div(class = "row",
div(class="col-4",
hr(),
selectInput(inputId = "province",
label = HTML("Province "),
choices = provinces,
selected = "Ontario",
selectize = FALSE,
width = select_input_width) %>%
helper(
colour = "grey",
type = "markdown",
content = "province")
)
)
))
server <- function(input, output, session) {
observe_helpers(help_dir = "info_files")
}
shinyApp(ui, server)
以下解决方法适合您。
ui <- bootstrapPage(
theme = bs_theme(version = 5,
"font-scale" = 1.0),
div(class = "container-fluid",
div(class = "row",
div(class="col-4",
hr(),
selectInput(inputId = "province",
label = helper(shiny_tag = "Province r", colour = "grey", type = "markdown", content = ''),
choices = provinces,
selected = "Ontario",
selectize = FALSE,
width = select_input_width)
)
)
))
Note :-
我在 helper
函数中提供了 Province r
作为参数值。这只是为了在文本和图标之间提供 space。如果我只包含 Province
作为值,那么图标会在文本末尾重叠。
如何移动 shinyhelper 图标“?”,使其恰好位于“Province”一词的右侧?
R 脚本
library(shiny)
library(magrittr)
library(shinyhelper)
library("bslib")
select_input_width <- "270px"
provinces <- c("British Columbia", "Alberta", "Saskatchewan", "Manitoba", "Ontario", "Quebec",
"New Brunswick", "Nova Scotia", "PEI", "Newfoundland and Labrador")
ui <- bootstrapPage(
theme = bs_theme(version = 5,
"font-scale" = 1.0),
div(class = "container-fluid",
div(class = "row",
div(class="col-4",
hr(),
selectInput(inputId = "province",
label = HTML("Province "),
choices = provinces,
selected = "Ontario",
selectize = FALSE,
width = select_input_width) %>%
helper(
colour = "grey",
type = "markdown",
content = "province")
)
)
))
server <- function(input, output, session) {
observe_helpers(help_dir = "info_files")
}
shinyApp(ui, server)
以下解决方法适合您。
ui <- bootstrapPage(
theme = bs_theme(version = 5,
"font-scale" = 1.0),
div(class = "container-fluid",
div(class = "row",
div(class="col-4",
hr(),
selectInput(inputId = "province",
label = helper(shiny_tag = "Province r", colour = "grey", type = "markdown", content = ''),
choices = provinces,
selected = "Ontario",
selectize = FALSE,
width = select_input_width)
)
)
))
Note :-
我在 helper
函数中提供了 Province r
作为参数值。这只是为了在文本和图标之间提供 space。如果我只包含 Province
作为值,那么图标会在文本末尾重叠。