| use_cleanrmd | R Documentation |
Provides a cleanrmd CSS theme using htmltools. You can use this
CSS theme anywhere that HTML dependencies are handled via
htmltools::htmlDependency(), for example in R Markdown or Quarto documents
or in Shiny apps.
use_cleanrmd(name = NULL)
cleanrmd_theme_dependency(name = NULL)
name |
The name of the theme, see |
use_cleanrmd() returns an htmltools::tagList() with an
htmltools::htmlDependency(). cleanrmd_theme_dependency() returns only
the htmltools::htmlDependency().
use_cleanrmd(): Use a clean CSS theme in the current document or app
(general usage)
cleanrmd_theme_dependency(): Use a clean CSS theme dependency (advanced usage)
In R Markdown (static or Shiny
prerendered), you should use the html_document_clean() output format to
use a cleanrmd theme.
---
output:
cleanrmd::html_document_clean:
theme: NULL # or pick a specific theme
self_contained: false
---
You can also use cleanrmd in Quarto documents
or apps (using server: shiny). You'll need to turn off the themes
provided by Quarto with theme: none and then call
cleanrmd::use_cleanrmd() in a code chunk in your document.
---
title: "Untitled"
format:
html:
theme: none
#server: shiny
---
```{r cleanrmd, echo=FALSE}
cleanrmd::use_cleanrmd("bamboo")
```
In Shiny apps, you'll need to use shiny::basicPage() rather than
shiny::fluidPage(). Then call use_cleanrmd() in your app to use a
cleanrmd theme.
library(shiny)
ui <- shiny::basicPage(
cleanrmd::use_cleanrmd(),
h2("Old Faithful Geyser Data"),
sliderInput(
"bins",
"Number of bins:",
min = 1,
max = 50,
value = 30
),
plotOutput("distPlot")
)
page <- htmltools::withTags(
main(
h2("Small Demo"),
p("Clean, simple, classy but class-less:"),
ul(
li("Works almost anywhere"),
li("Small and simple"),
li("Easy to extend"),
li("Good enough but not perfect")
)
)
)
# no styles
if (interactive()) {
htmltools::browsable(page)
}
# all clean styles
page_clean <- htmltools::tagList(page, use_cleanrmd())
if (interactive()) {
htmltools::browsable(page_clean)
}
# one clean style
page_water <- htmltools::tagList(page, use_cleanrmd("water"))
if (interactive()) {
htmltools::browsable(page_water)
}
cleanrmd_theme_dependency("bamboo")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.