如何强制使用相同的闪亮输入标签高度?
how to enforce same label height of shiny inputs?
问题描述
对于闪亮的应用程序,我想在我的应用程序中像布局一样在一行中并排显示多个 selectInputs
。不幸的是,如果标签中存在破坏应用程序流程的换行符,select 字段不会对齐。
情况
这是我的示例代码,我修改了 selectInput
:
描述中的示例
## Only run examples in interactive R sessions
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
mainPanel(
flowLayout(
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
),
selectInput("stat2", "Variable description with a way longer description to enforce linebreak:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
)),# end of inputs
textOutput("result"),
width = 12
)),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}
这导致:
目标
我希望输入字段始终处于同一高度水平,如下所示:
splitLayout
有点这样做,但如果页面要缩小标签并添加使 UI 复杂化的 y 滚动条,它就会崩溃,尤其是对于更大的标签:
不幸的是,我没有 WebDev 经验,因此有点不知所措。有人可以帮我解决这个问题吗?
CSS 成功了。
style = "display:flex;align-items:flex-end"
在 flowLayout 中包含此样式是否可以帮助您解决问题?
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
mainPanel(
flowLayout(
style = "display:flex;align-items:flex-end",
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
),
selectInput("stat2", "Variable description with a way longer description to enforce linebreak:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
)),# end of inputs
textOutput("result"),
width = 12
)),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}
问题描述
对于闪亮的应用程序,我想在我的应用程序中像布局一样在一行中并排显示多个 selectInputs
。不幸的是,如果标签中存在破坏应用程序流程的换行符,select 字段不会对齐。
情况
这是我的示例代码,我修改了 selectInput
:
## Only run examples in interactive R sessions
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
mainPanel(
flowLayout(
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
),
selectInput("stat2", "Variable description with a way longer description to enforce linebreak:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
)),# end of inputs
textOutput("result"),
width = 12
)),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}
这导致:
目标
我希望输入字段始终处于同一高度水平,如下所示:
splitLayout
有点这样做,但如果页面要缩小标签并添加使 UI 复杂化的 y 滚动条,它就会崩溃,尤其是对于更大的标签:
不幸的是,我没有 WebDev 经验,因此有点不知所措。有人可以帮我解决这个问题吗?
CSS 成功了。
style = "display:flex;align-items:flex-end"
在 flowLayout 中包含此样式是否可以帮助您解决问题?
if (interactive()) {
# demoing group support in the `choices` arg
shinyApp(
ui = fluidPage(
mainPanel(
flowLayout(
style = "display:flex;align-items:flex-end",
selectInput("state", "Choose a state:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
),
selectInput("stat2", "Variable description with a way longer description to enforce linebreak:",
list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
)),# end of inputs
textOutput("result"),
width = 12
)),
server = function(input, output) {
output$result <- renderText({
paste("You chose", input$state)
})
}
)
}