[英]Align ActionButton in Shiny App
In the app below, I would like to change three aspects of the ActionButton
:在下面的应用程序中,我想更改ActionButton
的三个方面:
Can this be done within shiny?这可以在 shiny 内完成吗?
library(shiny)
library(shinyBS)
ui <-
fluidPage(
fluidRow(
column(12,
bsCollapse(id="instructionsOutput", open="instructionsPanel",
bsCollapsePanel("instructionsPanel",
"This is a panel with text",
style="info"
)
)
),
column(12,
actionButton("p1Button", "Expand/Collapse Text")
)
),
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
server <- function(input, output, session) {
observeEvent(input$p1Button, ({
updateCollapse(session, "instructionsOutput",
open="instructionsPanel",
close="instructionsPanel")
})
)
}
shinyApp(ui, server)
Very late reply...but if anyone is looking for a possible solution, you can try the following.回复很晚...但如果有人正在寻找可能的解决方案,您可以尝试以下操作。 Similar to the answer by Xiongbing Jin above, you can add style
and align
as arguments to shiny::column
与上面 Xiongbing Jin 的回答类似,您可以将style
和align
作为参数添加到shiny::column
ui <-
fluidPage(
fluidRow(
column(
12,
bsCollapse(
id="instructionsOutput",
open="instructionsPanel",
bsCollapsePanel(
"instructionsPanel",
"This is a panel with text",
style="info"
)
)
),
column(
12,
actionButton(
"p1Button",
"Expand/Collapse Text"
)
, align = "center"
, style = "margin-bottom: 10px;"
, style = "margin-top: -10px;"
)
),
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
server <- function(input, output, session) {
observeEvent(input$p1Button, ({
updateCollapse(
session, "instructionsOutput",
open="instructionsPanel",
close="instructionsPanel"
)
})
)
}
shinyApp(ui, server)
Thanks @rhyncogale.谢谢@rhyncogale。 I applied your comment and it worked for my work.我应用了你的评论,它对我的工作有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.