rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
885 stars 300 forks source link

dynamic footer #391

Closed BirongZhang closed 1 year ago

BirongZhang commented 1 year ago

Dear all,

Thanks for developing such as useful tool! Brilliant work!

I was wondering how to build a dynamic footer. For example, you put a picture or some text on the footer, and when the user clicks on the footer, it can take users to another linked website. I found dashboardFooter, but this one is static.

Any advices would be highly appreciated! Thanks.

Kind regards, Birong

ismirsehregal commented 1 year ago

You might want to check shinydashboardPlus::dashboardFooter.

BirongZhang commented 1 year ago

You might want to check shinydashboardPlus::dashboardFooter.

Hi friend,

Thanks for your kind reply!

I also found this function before, shinydashboardPlus has very good example here, which is exactly what I want. But from this dashboardFooter tutorial, I can only add some simple text at the footer. I still don't know how to put the link behind the text and build a dynamic footer.

Is there any other advanced tutorials about this? Thanks.

Best regards, Birong

ismirsehregal commented 1 year ago

You are not limited to using text regarding those parameters. Please check the following:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    footer = dashboardFooter(
      left = uiOutput("htmlout"),
      right = textOutput("somethinguseful")
    ),
    title = "DashboardPage"
  ),
  server = function(input, output, session) {
    output$htmlout <- renderUI({
      strong("Please look at the lower right corner")  
    })
    output$somethinguseful <- renderText({
      invalidateLater(500)
      as.character(Sys.time())
    })
  }
)

PS: of course you could also directly use an img tag instead of renderUI.

BirongZhang commented 1 year ago

Hi friend,

Thanks for your reply! It helps a lot!

I was wondering if you could show me how to put a link behind "Please look at the lower right corner". For example, I click on "Please look at the lower right corner", and then shiny can open a website page for me. That would be great!

Sorry for being so annoying. Thanks.

ismirsehregal commented 1 year ago

As this is not a {shinydashboard} issue I guess you are better off asking those questions here:

https://stackoverflow.com/questions/tagged/shiny

or here:

https://community.rstudio.com/c/shiny/8

but nevertheless, there you go:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    footer = dashboardFooter(
      # with image
      left = a(target="_blank", href = 'https://www.google.com/',
               img(src = 'https://www.gstatic.com/images/branding/googlelogo/svg/googlelogo_clr_74x24px.svg', title = "visit google.com", height = "40px"),
               style = "padding-top:5px; padding-bottom:5px;"),
      # witout image:
      # left = a("Please look at the lower right corner", target="_blank", href = 'https://www.google.com/',
      #          style = "padding-top:5px; padding-bottom:5px;"),
      right = textOutput("somethinguseful")
    ),
    title = "DashboardPage"
  ),
  server = function(input, output, session) {
    output$somethinguseful <- renderText({
      invalidateLater(500)
      as.character(Sys.time())
    })
  }
)
BirongZhang commented 1 year ago

As this is not a {shinydashboard} issue I guess you are better off asking those questions here:

https://stackoverflow.com/questions/tagged/shiny

or here:

https://community.rstudio.com/c/shiny/8

but nevertheless, there you go:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    footer = dashboardFooter(
      # with image
      left = a(target="_blank", href = 'https://www.google.com/',
               img(src = 'https://www.gstatic.com/images/branding/googlelogo/svg/googlelogo_clr_74x24px.svg', title = "visit google.com", height = "40px"),
               style = "padding-top:5px; padding-bottom:5px;"),
      # witout image:
      # left = a("Please look at the lower right corner", target="_blank", href = 'https://www.google.com/',
      #          style = "padding-top:5px; padding-bottom:5px;"),
      right = textOutput("somethinguseful")
    ),
    title = "DashboardPage"
  ),
  server = function(input, output, session) {
    output$somethinguseful <- renderText({
      invalidateLater(500)
      as.character(Sys.time())
    })
  }
)

Many thanks! 👍