File: htmlwidgets-shiny.Rd

package info (click to toggle)
r-cran-htmlwidgets 1.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 500 kB
  • sloc: javascript: 597; makefile: 2
file content (87 lines) | stat: -rw-r--r-- 2,943 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlwidgets.R
\name{htmlwidgets-shiny}
\alias{htmlwidgets-shiny}
\alias{shinyWidgetOutput}
\alias{shinyRenderWidget}
\title{Shiny bindings for HTML widgets}
\usage{
shinyWidgetOutput(
  outputId,
  name,
  width,
  height,
  package = name,
  inline = FALSE,
  reportSize = TRUE,
  reportTheme = FALSE,
  fill = !inline
)

shinyRenderWidget(expr, outputFunction, env, quoted, cacheHint = "auto")
}
\arguments{
\item{outputId}{output variable to read from}

\item{name}{Name of widget to create output binding for}

\item{width, height}{Must be a valid CSS unit (like \code{"100\%"},
\code{"400px"}, \code{"auto"}) or a number, which will be coerced to a
string and have \code{"px"} appended.}

\item{package}{Package containing widget (defaults to \code{name})}

\item{inline}{use an inline (\code{span()}) or block container (\code{div()})
for the output}

\item{reportSize}{Should the widget's container size be reported in the
shiny session's client data?}

\item{reportTheme}{Should the widget's container styles (e.g., colors and fonts)
be reported in the shiny session's client data?}

\item{fill}{whether or not the returned tag should be treated as a fill item,
meaning that its \code{height} is allowed to grow/shrink to fit a fill container
with an opinionated height (see \code{\link[htmltools:bindFillRole]{htmltools::bindFillRole()}} for more).
Examples of fill containers include \code{bslib::card()} and
\code{bslib::card_body_fill()}.}

\item{expr}{An expression that generates an HTML widget (or a
\href{https://rstudio.github.io/promises/}{promise} of an HTML widget).}

\item{outputFunction}{Shiny output function corresponding to this render
function.}

\item{env}{The environment in which to evaluate \code{expr}.}

\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
is useful if you want to save an expression in a variable.}

\item{cacheHint}{Extra information to use for optional caching using
\code{shiny::bindCache()}.}
}
\value{
An output or render function that enables the use of the widget
within Shiny applications.
}
\description{
Helpers to create output and render functions for using HTML widgets within
Shiny applications and interactive Rmd documents.
}
\details{
These functions are delegated to from within your widgets own shiny
output and render functions. The delegation is boilerplate and always works
the same for all widgets (see example below).
}
\examples{
# shiny output binding for a widget named 'foo'
fooOutput <- function(outputId, width = "100\%", height = "400px") {
  htmlwidgets::shinyWidgetOutput(outputId, "foo", width, height)
}

# shiny render function for a widget named 'foo'
renderFoo <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  htmlwidgets::shinyRenderWidget(expr, fooOutput, env, quoted = TRUE)
}
}