r-当闪亮的应用程序首次启动时显示一个按钮,该按钮将导致tabItems内容



我有下面的shiny应用程序,其中包括tabItems。我希望当应用程序第一次启动时显示一个actionbutton,它将在tabItems内容之外。然后,当我按下它时,我将进入Consent选项卡项。该按钮从此以后将不再使用,并且应该消失,因为tabItems的内容将显示出来。

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
mytitle <- paste0("")
dbHeader <- dashboardHeaderPlus(
titleWidth = "0px",
tags$li(a(
div(style="display: inline;margin-top:-35px; padding: 0px 90px 0px 1250px ;font-size: 44px ;color:#001641;font-family:Chronicle Display Light; width: 500px;",HTML(mytitle)),


div(style="display: inline;padding: 0px 0px 0px 0px;vertical-align:top; width: 150px;", actionButton("conse", "Consent", 
                                   style=" background-color: #faf0e6; border-color: #faf0e6")),

),
class = "dropdown")


)
shinyApp(
ui = dashboardPagePlus(
header = dbHeader,
sidebar = dashboardSidebar(width = "0px",
sidebarMenu(id = "sidebar", # id important for updateTabItems
menuItem("Consent", tabName = "conse", icon = icon("line-chart"))
)           ),
body = dashboardBody(
tags$head(tags$style(HTML('

'))),
useShinyjs(),
tags$script(HTML("$('body').addClass('fixed');")),

tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),

actionButton("button", "Get started",style='padding:4px; font-size:140%'),
tabItems(
tabItem("conse",
textInput("pos", label = ("Position"), value = "")
)

)

)

),
server<-shinyServer(function(input, output,session) { 
hide(selector = "body > div > header > nav > a")


observeEvent(input$button, {

updateTabItems(session, "sidebar",
selected = "conse")


})

}
)
)

也许你正在寻找这个

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
mytitle <- paste0("")
dbHeader <- dashboardHeaderPlus(
titleWidth = "0px",
tags$li(a(
div(style="display: inline;margin-top:-35px; padding: 0px 90px 0px 1250px ;font-size: 44px ;color:#001641;font-family:Chronicle Display Light; width: 500px;",HTML(mytitle)),

div(style="display: inline;padding: 0px 0px 0px 0px;vertical-align:top; width: 150px;", actionButton("conse", "Consent",
                                   style=" background-color: #faf0e6; border-color: #faf0e6") ),
),  class = "dropdown")
)
shinyApp(
ui = dashboardPagePlus(
header = dbHeader,
sidebar = dashboardSidebar(width = "0px",
sidebarMenu(id = "sidebar", # id important for updateTabItems
menuItem("Consent", tabName = "conse", icon = icon("line-chart"))
)           ),
body = dashboardBody(
tags$head(tags$style(HTML('
'))),
useShinyjs(),
tags$script(HTML("$('body').addClass('fixed');")),
tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),
actionButton("button", "Get started",style='padding:4px; font-size:140%'),
tabItems(
tabItem("conse", textInput("pos", label = ("Position"), value = "") )
)
)
),
server<-shinyServer(function(input, output,session) {
hide(selector = "body > div > header > nav > a")
shinyjs::hide("conse")
shinyjs::hide("pos")
observeEvent(input$button, {
shinyjs::show("conse")
shinyjs::show("pos")
updateTabItems(session, "sidebar",
selected = "conse")
shinyjs::hide("button")
})
}
)
)

相关内容

最新更新