Q:

In shiny, is it possible to get the size of an ui element in the server?

I am building an app in shiny, that generates a custom svg file. When doing so, I would like to adapt the resolution to the element of the ui (in my case, a box from shinydashboard) it will be placed in.
Is there a way for my code in server.R to query the size (in pixels) of a box in the ui ?
I would imagine something like: ui$mybox$height and  ui$mybox$width

A:

I found out that you can indeed access some information about the ui from the server.
To answer the question, you can get the width and height of an element created with plotOutput("plot1") using session$clientData[["output_plot1_width"]] and session$clientData[["output_plot1_height"]].
To get an exhaustive list of what info is available in a given session, go in debug-mode in a reactive expression in server.R (for instance in renderText() and type reactiveValuesToList(session$clientData).

