将选项名称放在闪亮的单选按钮上方
putting choice names above the radiobutton in shiny
我正在用 r shiny 开发 ui。在某些时候我使用水平分布的单选按钮
radioButtons("my_rb","choose:",1:3,inline=T)
我得到的是单选按钮,它们的名称在同一行
choose: 1 [] 2 [] 3 []
我真正想要的是:
choose: 1 2 3
[] [] []
有办法实现吗?
使用 tags$head
在 UI 的顶部添加一些 CSS 似乎可以达到您想要的结果:
ui <- fluidPage(
tags$head(
tags$style(HTML("
.shiny-input-radiogroup label {
display: inline-block;
text-align: center;
}
.shiny-input-radiogroup label input[type='radio'] {
display: block;
margin: 2em auto;
}
"))
),
# rest of your UI code
)
这是它的样子:
我正在用 r shiny 开发 ui。在某些时候我使用水平分布的单选按钮
radioButtons("my_rb","choose:",1:3,inline=T)
我得到的是单选按钮,它们的名称在同一行
choose: 1 [] 2 [] 3 []
我真正想要的是:
choose: 1 2 3
[] [] []
有办法实现吗?
使用 tags$head
在 UI 的顶部添加一些 CSS 似乎可以达到您想要的结果:
ui <- fluidPage(
tags$head(
tags$style(HTML("
.shiny-input-radiogroup label {
display: inline-block;
text-align: center;
}
.shiny-input-radiogroup label input[type='radio'] {
display: block;
margin: 2em auto;
}
"))
),
# rest of your UI code
)
这是它的样子: