| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/shiny.R |
| 3 |
\name{getCurrentOutputInfo} |
| 4 |
\alias{getCurrentOutputInfo} |
| 5 |
\title{Get output information} |
| 6 |
\usage{ |
| 7 |
getCurrentOutputInfo(session = getDefaultReactiveDomain()) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{session}{The current Shiny session.} |
| 11 |
} |
| 12 |
\value{ |
| 13 |
\code{NULL} if called outside of an output context; otherwise, |
| 14 |
a list which includes: |
| 15 |
\itemize{ |
| 16 |
\item The \code{name} of the output (reported for any output). |
| 17 |
\item If the output is a \code{plotOutput()} or \code{imageOutput()}, then: |
| 18 |
\itemize{ |
| 19 |
\item \code{height}: a reactive expression which returns the height in pixels. |
| 20 |
\item \code{width}: a reactive expression which returns the width in pixels. |
| 21 |
} |
| 22 |
\item If the output is a \code{plotOutput()}, \code{imageOutput()}, or contains a \code{shiny-report-theme} class, then: |
| 23 |
\itemize{ |
| 24 |
\item \code{bg}: a reactive expression which returns the background color. |
| 25 |
\item \code{fg}: a reactive expression which returns the foreground color. |
| 26 |
\item \code{accent}: a reactive expression which returns the hyperlink color. |
| 27 |
\item \code{font}: a reactive expression which returns a list of font information, including: |
| 28 |
\itemize{ |
| 29 |
\item \code{families}: a character vector containing the CSS \code{font-family} property. |
| 30 |
\item \code{size}: a character string containing the CSS \code{font-size} property |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
\description{ |
| 36 |
Returns information about the currently executing output, including its \code{name} (i.e., \code{outputId}); |
| 37 |
and in some cases, relevant sizing and styling information. |
| 38 |
} |
| 39 |
\examples{ |
| 40 |
|
| 41 |
if (interactive()) { |
| 42 |
shinyApp( |
| 43 |
fluidPage( |
| 44 |
tags$style(HTML("body {background-color: black; color: white; }")), |
| 45 |
tags$style(HTML("body a {color: purple}")), |
| 46 |
tags$style(HTML("#info {background-color: teal; color: orange; }")), |
| 47 |
plotOutput("p"), |
| 48 |
"Computed CSS styles for the output named info:", |
| 49 |
tagAppendAttributes( |
| 50 |
textOutput("info"), |
| 51 |
class = "shiny-report-theme" |
| 52 |
) |
| 53 |
), |
| 54 |
function(input, output) { |
| 55 |
output$p <- renderPlot({ |
| 56 |
info <- getCurrentOutputInfo() |
| 57 |
par(bg = info$bg(), fg = info$fg(), col.axis = info$fg(), col.main = info$fg()) |
| 58 |
plot(1:10, col = info$accent(), pch = 19) |
| 59 |
title("A simple R plot that uses its CSS styling") |
| 60 |
}) |
| 61 |
output$info <- renderText({ |
| 62 |
info <- getCurrentOutputInfo() |
| 63 |
jsonlite::toJSON( |
| 64 |
list( |
| 65 |
bg = info$bg(), |
| 66 |
fg = info$fg(), |
| 67 |
accent = info$accent(), |
| 68 |
font = info$font() |
| 69 |
), |
| 70 |
auto_unbox = TRUE |
| 71 |
) |
| 72 |
}) |
| 73 |
} |
| 74 |
) |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
} |