Skip to content

page_navbar footer options #1212

Open
Open
@nathanj3

Description

@nathanj3

I'm making a multi-page Shiny app using page_navbar with multiple nav_panels, which includes a main set of panels plus "Help" and "About" panels at the end.

I've written some custom Shiny module code to add a sticky footer at the bottom of the viewport using divs and css classes, which I apply on a per-panel basis using (a) a class definition, which goes into the app as a free-floating HTML chunk, and (b) a wrapper function around each page that needs the footer. (I can provide more detail if this is unclear.)

ui <- page_navbar(
  title = "UI demo",
  id = "ui-demo",
  ),
  # This object defines the css classes for the footer with next/back buttons 
  # i.e., in the module file, navButtonsSetup <- tags$head(tags$style(HTML(" .sticky-footer { ...}" [etc.])))
  navButtonsSetup,
  
  nav_panel(
    "Overview",
    value = "overview",
    layout_columns(
      col_widths = c(-2, 8, -2),
      row_heights = c(1,6),
      random_text(nwords = 10),
      random_DT(nrow = 20, ncol = 5)
    ) |> addNavButtons("overview_page") # addNavButtons is a Shiny UI module
  ),
[etc.]

The footer contains "next" and "back" buttons to toggle between the three main nav panels. The "Help" and "About" pages do not have the footer, because I don't want users to navigate to them using the "next" button.

Panel with footer

The "Help" and "About" pages do not have the footer, because I don't want users to navigate to them using the "next" button--that would be confusing.

About panel, does not have footer

When I run my app, I get the warning that Navigation containers expect a collection of `bslib::nav_panel()`/`shiny::tabPanel()`s and/or `bslib::nav_menu()`/`shiny::navbarMenu()`s and that I should Consider using `header` or `footer` if you wish to place content above (or below) every panel's contents.

I like the idea of using the built-in header or footer, but it doesn't currently work for my setup (as best as I can tell) because I have 3 panels with a footer, plus 2 panels that need to not have it.

Possible feature

Would it be feasible to either:

  1. allow the header and footer arguments of page_navbar to take a list or a named vector, to match one item per page, such as: footer = list(Data = my_footer, Overview = my_footer, Help = NULL, About = NULL) , or
  2. provide nav_panel with an overwrite_header / overwrite_footer option to let a specific panel "opt out" of the default header/footer?

Thanks in advance for reading through this, please let me know if you need any more details or if there's an existing solution I should know about. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions