in Shiny, how to connect landing pages?

I am creating Shiny app with multiple landing pages some of them need to be connected. The sample here shows that in the home page, the select input "home" is selected and in the dashboard body two widgets the 1st one is "clients" with action button "click here". I need this button to lead to the same landing page if i selected "Clients" from the SelectInput Or should I create a link to facilitate jumping to any page Here is a GIF showing what I'm looking for

the used code

library(shiny)
library(shinydashboardPlus)
library(DT)
library(readxl)
library(dplyr)
library(formattable)
library(shinydashboard)
library(shinyjqui)
library(shinyjs)
library(shinythemes)
library(markdown)


title <- tags$a(href= NULL, tags$img(src ="BM_fl.png", onclick =     "selectInput('Home')", height = '55',  style = "padding-bottom:10px;"))
ui = fluidPage(theme=shinytheme("superhero"),
           dashboardPage(
             dashboardHeader(title = title, titleWidth = 230), 
             dashboardSidebar(selectInput("listofitems","Items     List",c("Home","Group","Clients"), selected = "Home")),
             dashboardBody(uiOutput("ui_myHome"),
                           uiOutput("ui_myclients")))) 


shinyServer(function(input, output, session) {
output$ui_myHome<-renderUI({if (input$listofitems == 'Home'){(
  fluidPage(
    widgetUserBox(
      title = "Clients",
      shiny::actionButton(inputId='clientsmainbutton', label="Click here"),
      type = 2, src = "https://adminlte.io/themes/AdminLTE/dist/img/user7-128x128.jpg", color = "yellow"),
    widgetUserBox(
      title = "Facts",
      shiny::actionButton(inputId='ab1', label="Click here"),
      type = 2, src = "https://adminlte.io/themes/AdminLTE/dist/img/user7-128x128.jpg", color = "yellow")))}

else if (input$listofitems == 'Clients'){(Clientsbutton<- fluidPage(
                                              widgetUserBox(title = "Global",shiny::actionButton(inputId='ab1', label="Click here"),
                                                type = 2, src = "https://adminlte.io/themes/AdminLTE/dist/img/user7-128x128.jpg", 
                                                color = "red")))}})})

If I understand correctly, it seems like you could just add the following to your server logic?

observeEvent(input$clientsmainbutton, {
   updateSelectInput(session, "listofitems", selected = "Clients")
 })
1 Like

Thank you, for your usual support :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.