Description
I'm making a multi-page Shiny app using page_navbar
with multiple nav_panel
s, 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.
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.
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:
- allow the
header
andfooter
arguments ofpage_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 - provide
nav_panel
with anoverwrite_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. :)