Title: | Update Browser Window Title in 'shiny' Session |
---|---|
Description: | Enables the ability to change or flash the title of the browser window during a 'shiny' session. |
Authors: | Ashley Baldry [aut, cre] |
Maintainer: | Ashley Baldry <[email protected]> |
License: | GPL-2 |
Version: | 0.1.0 |
Built: | 2025-02-24 04:18:03 UTC |
Source: | https://github.com/ashbaldry/shinytitle |
Change the text in the browser tab whenever the shiny application is processing any server-side code.
busy_window_title(title = "Running...")
busy_window_title(title = "Running...")
title |
String to give the window title. |
The browser tab title will change whenever the shiny application is in a 'busy' state.
Add use_shiny_title
within the UI for busy_window_title
to work.
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), busy_window_title("Sleeping..."), actionButton("button", "Click me for a 5 second busy title") ) server <- function(input, output, session) { observeEvent(input$button, Sys.sleep(5)) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), busy_window_title("Sleeping..."), actionButton("button", "Click me for a 5 second busy title") ) server <- function(input, output, session) { observeEvent(input$button, Sys.sleep(5)) } shinyApp(ui, server) }
Change the text that is present in the browser tab.
change_window_title( session = shiny::getDefaultReactiveDomain(), title = "Ready!", inactive_only = FALSE, revert_on_focus = inactive_only )
change_window_title( session = shiny::getDefaultReactiveDomain(), title = "Ready!", inactive_only = FALSE, revert_on_focus = inactive_only )
session |
The |
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 |
revert_on_focus |
Logical, should the title revert back to the original title when the tab is in
focus/active again? Only works when |
The browser tab title will change to the new specified title.
Add use_shiny_title
within the UI for change_window_title
to work.
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) }
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) }
Alternate the text in the browser tab between the current text and the new specified text.
flashing_window_title( session = shiny::getDefaultReactiveDomain(), title = "Ready!", inactive_only = FALSE, revert_on_focus = inactive_only, revert_on_mousemove = TRUE, interval = 500, duration = 0 )
flashing_window_title( session = shiny::getDefaultReactiveDomain(), title = "Ready!", inactive_only = FALSE, revert_on_focus = inactive_only, revert_on_mousemove = TRUE, interval = 500, duration = 0 )
session |
The |
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 |
revert_on_focus |
Logical, should the title revert back to the original title when the tab is in
focus/active again? Only works when |
revert_on_mousemove |
Logical, should the title revert back to the original title when the mouse
is moved in the tab? Default is set to |
interval |
Time (in milliseconds) to flip between the original title and the new title. |
duration |
Time (in milliseconds) to stop flashing the title. 0 (the default) means it will flash indefinitely. |
The browser tab title will change between the original and newly specified title.
Add use_shiny_title
within the UI for flashing_window_title
to work.
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), actionButton("button", "Click me for a 10 second flashing title"), actionButton("button2", "Click me for a delayed flashing button") ) server <- function(input, output, session) { observeEvent(input$button, { flashing_window_title( session, "--- Flash ---", revert_on_mousemove = FALSE, duration = 10000 ) }) observeEvent(input$button2, { Sys.sleep(3) flashing_window_title( session, "Please Come Back", inactive_only = TRUE, interval = 1000 ) }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), actionButton("button", "Click me for a 10 second flashing title"), actionButton("button2", "Click me for a delayed flashing button") ) server <- function(input, output, session) { observeEvent(input$button, { flashing_window_title( session, "--- Flash ---", revert_on_mousemove = FALSE, duration = 10000 ) }) observeEvent(input$button2, { Sys.sleep(3) flashing_window_title( session, "Please Come Back", inactive_only = TRUE, interval = 1000 ) }) } shinyApp(ui, server) }
Launch one of the examples contained in the shinytitle
package:
toggleAn example showing the effects of simple change to the title and flashing title
busyAn example of when the title changes when the shiny app is busy running calculations
run_shinytitle_example(example = c("toggle", "busy"), ...)
run_shinytitle_example(example = c("toggle", "busy"), ...)
example |
Choose between |
... |
other arguments sent to |
if (interactive()) { library(shiny) run_shinytitle_example() }
if (interactive()) { library(shiny) run_shinytitle_example() }
shinytitle
Add this function to the UI of a shiny application in order for you to be able to update the browser title.
use_shiny_title()
use_shiny_title()
A script tag that enables shinytitle
to work within a shiny app.
change_window_title
flashing_window_title
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), actionButton("button", "Click me for a new title"), ) server <- function(input, output, session) { observeEvent(input$button, { change_window_title(session, "New Title") }) } shinyApp(ui, server) }
if (interactive()) { library(shiny) ui <- fluidPage( title = "Initial Title", use_shiny_title(), actionButton("button", "Click me for a new title"), ) server <- function(input, output, session) { observeEvent(input$button, { change_window_title(session, "New Title") }) } shinyApp(ui, server) }