[英]How to Reduce sidebarPanel Text Size in Shiny?
我将如何减少文字大小和selectInput
在我的盒子大小Shiny
应用程序?
现在,我有四个selectInput
框和相应的标题,它们非常大。 我希望包含多达16个,但尺寸减小。 我在Shiny
教程中包含了一个示例ui.R
谢谢你的帮助!
更新:我使用tags$style
line更新了以下代码。 这使文本更小。 现在,我不确定如何使selectInput框更小。
shinyUI(fluidPage(
titlePanel("censusVis"),
sidebarLayout(
sidebarPanel(
helpText("Create demographic maps with
information from the 2010 US Census."),
tags$style(type='text/css', ".selectize-input { font-size: 10px; line-height: 10px;} .selectize-dropdown { font-size: 10px; line-height: 10px; }")
selectInput("var",
label = "Choose a variable to display",
choices = c("Percent White", "Percent Black",
"Percent Hispanic", "Percent Asian"),
selected = "Percent White"),
sliderInput("range",
label = "Range of interest:",
min = 0, max = 100, value = c(0, 100))
),
mainPanel(
textOutput("text1")
)
)
))
要减小字体大小,只需在文档标题中添加一些CSS,定位"selectize-input"
和"selectize-dropdown"
类的元素。 (这些分别影响选择栏和下拉菜单中显示的字体大小。)
要减小控件的宽度,可以将其包装在fluidRow()
并将其分配给该行包含的12列中的一小部分。
这是一个完全可重现的示例,您只需将其复制并粘贴到R中即可运行:
library(shiny)
shinyApp(
ui = fluidPage(
tags$head(tags$style(HTML("
.selectize-input, .selectize-dropdown {
font-size: 75%;
}
"))),
titlePanel("censusVis"),
sidebarLayout(
sidebarPanel(
helpText("Create demographic maps with
information from the 2010 US Census."),
fluidRow(column(6,
selectInput("var",
label = "Choose a variable to display",
choices = c("Percent White", "Percent Black",
"Percent Hispanic", "Percent Asian"),
selected = "Percent White")
)),
sliderInput("range",
label = "Range of interest:",
min = 0, max = 100, value = c(0, 100))
),
mainPanel(textOutput("text1"))
)
),
server = function(input, output) {}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.