get_width: Get user's browser dimensions (in pixels)

View source: R/get_info.R

get_widthR Documentation

Get user's browser dimensions (in pixels)

Description

The value is reactive, therefore it must be accessed inside a reactive context (such as an observe or reactive).

{shinybrowser} must be initialized with a call to detect() in the app's ui.

Usage

get_width()

get_height()

Value

User's detected browser width in pixels

User's detected browser height in pixels

Width and height

The width and height of the browser window are only reported once, when the detect() function is initially called. If the user resizes the browser window, the new dimensions are not reported until the page is refreshed.

See Also

detect(), get_all_info()

Examples

if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    shinybrowser::detect(),
    "Your browser dimensions:",
    textOutput("browser_dim")
  )
  server <- function(input, output, session) {
    output$browser_dim <- renderText({
      paste0(shinybrowser::get_width(), "x", shinybrowser::get_height())
    })
  }
  shinyApp(ui, server)
}

daattali/shinybrowser documentation built on Aug. 21, 2024, 6:12 a.m.