File: bs_current_theme.Rd

package info (click to toggle)
r-cran-bslib 0.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,332 kB
  • sloc: javascript: 10,075; makefile: 30; sh: 23
file content (40 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bs-current-theme.R
\name{bs_current_theme}
\alias{bs_current_theme}
\title{Obtain the currently active theme at render time}
\usage{
bs_current_theme(session = get_reactive_domain())
}
\arguments{
\item{session}{The current Shiny session (if any).}
}
\value{
a \code{\link[=bs_theme]{bs_theme()}} object.
}
\description{
Intended for advanced use by developers to obtain the currently active theme
\emph{at render time} and primarily for implementing themable widgets that can't
otherwise be themed via \code{\link[=bs_dependency_defer]{bs_dependency_defer()}} .
}
\details{
This function should generally only be called at print/render time. For
example:
\itemize{
\item Inside the \code{preRenderHook} of \code{htmlwidgets::createWidget()}.
\item Inside of a custom \link{print} method that generates \link[htmltools:builder]{htmltools::tags}.
\item Inside of a \code{\link[htmltools:tagFunction]{htmltools::tagFunction()}}
}

Calling this function at print/render time is important because it does
different things based on the context in which it's called:
\itemize{
\item If a reactive context is active, \code{session$getCurrentTheme()} is called
(which is a reactive read).
\item If no reactive context is active, \code{shiny::getCurrentTheme()} is called
(which returns the current app's \code{theme}, if relevant).
\item If \code{shiny::getCurrentTheme()} comes up empty, then \code{bs_global_get()}
is called, which is relevant for \code{\link[rmarkdown:html_document]{rmarkdown::html_document()}}, and
possibly other static rendering contexts.
}
}