File: run_with_themer.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 (86 lines) | stat: -rw-r--r-- 2,962 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bs-theme-preview.R
\name{run_with_themer}
\alias{run_with_themer}
\alias{bs_themer}
\title{Theme customization UI}
\usage{
run_with_themer(appDir = getwd(), ..., gfonts = TRUE, gfonts_update = FALSE)

bs_themer(gfonts = TRUE, gfonts_update = FALSE)
}
\arguments{
\item{appDir}{The application to run. This can be a file or directory path,
or a \code{\link[shiny:shinyApp]{shiny::shinyApp()}} object. See \code{\link[shiny:runApp]{shiny::runApp()}} for details.}

\item{...}{Additional parameters to pass through to \code{\link[shiny:runApp]{shiny::runApp()}}.}

\item{gfonts}{whether or not to detect Google Fonts and wrap them in
\code{\link[=font_google]{font_google()}} (so that their font files are automatically imported).}

\item{gfonts_update}{whether or not to update the internal database of
Google Fonts.}
}
\value{
nothing. These functions are called for their side-effects.
}
\description{
A 'real-time' theme customization UI that you can use to easily make common
tweaks to Bootstrap variables and immediately see how they would affect your
app's appearance. There are two ways you can launch the theming UI. For most
Shiny apps, just use \code{run_with_themer()} in place of \code{\link[shiny:runApp]{shiny::runApp()}}; they
should take the same arguments and work the same way. Alternatively, you can
call the \code{bs_themer()} function from inside your server function (or in an R
Markdown app that is using \code{runtime: shiny}, you can call this from any code
chunk). Note that this function is only intended to be used for development!
}
\details{
To help you utilize the changes you see in the preview, this utility prints
\code{\link[=bs_theme]{bs_theme()}} code to the R console.
}
\section{Limitations}{

\itemize{
\item Doesn't work with Bootstrap 3.
\item Doesn't work with IE11.
\item Only works inside Shiny apps and \code{runtime: shiny} R Markdown documents.
\itemize{
\item Can't be used with static R Markdown documents.
\item Can be used to some extent with \code{runtime: shiny_prerendered}, but only UI
rendered through a \code{context="server"} may update in real-time.
}
\item Doesn't work with '3rd party' custom widgets that don't make use of
\code{\link[=bs_dependency_defer]{bs_dependency_defer()}} or \code{\link[=bs_current_theme]{bs_current_theme()}}.
}
}

\examples{
library(shiny)

ui <- fluidPage(
  theme = bs_theme(bg = "black", fg = "white"),
  h1("Heading 1"),
  h2("Heading 2"),
  p(
    "Paragraph text;",
    tags$a(href = "https://www.rstudio.com", "a link")
  ),
  p(
    actionButton("cancel", "Cancel"),
    actionButton("continue", "Continue", class = "btn-primary")
  ),
  tabsetPanel(
    tabPanel("First tab",
      "The contents of the first tab"
    ),
    tabPanel("Second tab",
      "The contents of the second tab"
    )
  )
)

if (interactive()) {
  run_with_themer(shinyApp(ui, function(input, output) {}))
}

}