Skip to content

How to semantically add JS to the head of a page_navbar? #898

Answered by gadenbuie
MayaGans asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MayaGans! You have three options:

  1. Stick it in one of the nav_panel()s.
  2. or use one of the header or footer arguments of page_navbar().
library(shiny)
library(bslib)

ui <- page_navbar(
   title = "My App",
   header = tags$head(tags$script("alert('👋 hello hello!')")),
   nav_panel(title = "One", p("First page content.")),
   nav_panel(title = "Two", p("Second page content."))
)

shinyApp(ui, \(...) { })

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MayaGans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants