r - 更改标记的大小、颜色和 dragulaInput 的文本
问题描述
我使用包esquisse
来创建输入,我想知道如何更改徽章、颜色文本和徽章颜色的大小?
if (interactive()) {
library("shiny")
library("esquisse")
ui <- fluidPage(
tags$h2("Demo dragulaInput"),
tags$br(),
dragulaInput(
inputId = "dad",
sourceLabel = "Old",
targetsLabels = c("New"),
choices = levels(iris[,"Species"]),
width = "250px",
height = "100px",
status = "danger"
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
new_level <- input$dad$target$New
new_level_1 <- c(new_level,input$dad$source)
})
}
shinyApp(ui = ui, server = server)
}
解决方案
您必须更改徽章的 css 属性。如果您检查徽章 html,您会看到它们都位于<span>
带有id=label-dragula label label-danger
.
由于 span 标签不响应高度和宽度指令,因此您必须将其转换为 inline-block 元素以更改大小(感谢这篇文章)。所有这些都在tags$style()
函数中完成 - 宽度和高度是不言自明的,背景颜色是徽章的颜色,颜色是文本的颜色。
library("shiny")
library("esquisse")
ui <- fluidPage(
tags$h2("Demo dragulaInput"),
tags$br(),
tags$style("
span.label-danger{
display: inline-block;
width: 75px;
height: 75px;
background-color: blue;
color: red;
font-size: 25px;
}
"),
dragulaInput(
inputId = "dad",
sourceLabel = "Old",
targetsLabels = c("New"),
choices = levels(iris[,"Species"]),
width = "250px",
height = "200px",
status = "danger"
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
new_level <- input$dad$target$New
new_level_1 <- c(new_level,input$dad$source)
})
}
shinyApp(ui = ui, server = server)
推荐阅读
- visual-studio-mac - Visual Studio for Mac 中的 CodeLens
- python - 在 Python 中使用 strptime 进行时间比较
- json - WSO2 ESB:空字段(“”)被添加为空,我不能让它们保持为空字符串
- android - 应用关闭时如何处理前台服务产生的数据?
- python - 如何获取标签文本变量的值
- oracle - 我们可以直接从命令行在 sqlcl 中运行 javascript,还是需要一个 sql 包装脚本?
- wordpress - WordPress Multisite - 从站点到站点克隆 CPT 页面 + 内容(包括 ACF 灵活内容)
- react-native - ApolloClient 缓存不会存储每个项目
- node.js - 将 Nginx 配置为 Jelastic 上 Nodejs 应用程序的反向代理
- javascript - 首次渲染后 Redux 状态在方法中未正确显示