change_window_title: Change Browser Title

Description Usage Arguments Value Note Examples

View source: R/title.R

Description

Change the text that is present in the browser tab.

Usage

1
2
3
4
5
6
change_window_title(
  session = shiny::getDefaultReactiveDomain(),
  title = "Ready!",
  inactive_only = FALSE,
  revert_on_focus = inactive_only
)

Arguments

session

The session object passed to function given to shinyServer. Default is getDefaultReactiveDomain().

title

String to give the window title

inactive_only

Logical, whether or not the title should only change if the tab is not active. Default is set to FALSE

revert_on_focus

Logical, should the title revert back to the original title when the tab is in focus/active again? Only works when inactive_only = TRUE.

Value

The browser tab title will change to the new specified title.

Note

Add use_shiny_title within the UI for change_window_title to work.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    title = "Initial Title",
    use_shiny_title(),
    actionButton("button", "Click me for a new title"),
    actionButton("button2", "Click me for a button when finished")
  )

  server <- function(input, output, session) {
    observeEvent(input$button, {
      change_window_title(session, "New Title")
    })

    observeEvent(input$button2, {
      Sys.sleep(3)
      change_window_title(session, "Sleep Finished", inactive_only = TRUE)
    })
  }

  shinyApp(ui, server)
}

shinytitle documentation built on June 16, 2021, 5:08 p.m.