rstudio / rstudio/bslib

`page_navbar` footer options

Open
#1,212 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

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. :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the warning with page_navbar, its nav_panel entries, and the current header/footer arguments in a small Shiny app. Read the page_navbar and nav_panel behavior around per-panel content, then determine whether selective footers can be supported without breaking navigation-container validation. Done means the requested panels show the footer while Help and About do not, with coverage for the chosen API.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.