get_width {shinybrowser} | R 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
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)
}
[Package shinybrowser version 1.0.0 Index]