Learn R Programming

cleanrmd (version 0.1.1)

use_cleanrmd: Use a clean CSS theme from cleanrmd

Description

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.

Usage

use_cleanrmd(name = NULL)

cleanrmd_theme_dependency(name = NULL)

Value

use_cleanrmd() returns an htmltools::tagList() with an htmltools::htmlDependency(). cleanrmd_theme_dependency() returns only the htmltools::htmlDependency().

Arguments

name

The name of the theme, see cleanrmd_themes() for a list of available themes. If NULL, all themes will be loaded with a simple drop down theme picker.

Functions

  • 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)

R Markdown documents

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
---

Quarto documents

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") ```

Shiny apps

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") )

Examples

Run this code
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")

Run the code above in your browser using DataLab