Home

Awesome

<!-- badges: start -->

R build
status CRAN
status Lifecycle:
experimental

<!-- badges: end -->

htmltools <a href='https://rstudio.github.io/htmltools/'><img src='man/figures/logo.png' align="right" height="138" /></a>

Tools for creating, manipulating, and writing HTML from R.

Installation

Install the stable release of htmltools on CRAN:

install.packages("htmltools")

Install the development version with:

remotes::install_github("rstudio/htmltools")

Quick overview

{htmltools} makes it easy to customize the user interface (UI) of any Shiny or R Markdown project by using R code to generate custom HTML (including JavaScript and CSS).

This Shiny article provides a great introduction to {htmltools} (even if you're not interested in Shiny). As you'll learn in that article, the general foundation that {htmltools} provides allows other R packages (e.g., {htmlwidgets}, {crosstalk}, etc.) to provide "HTML components" in R that users can manipulate and combine in ways the component authors didn't foresee.

For example, as described in depth here, {htmltools} makes it fairly easy to arrange numerous {htmlwidgets} (e.g., {plotly} graphs) into a single static HTML webpage:

library(htmltools)
library(plotly)
browsable(tagList(
  plot_ly(diamonds, x = ~carat, height = 200),
  plot_ly(diamonds, x = ~price, height = 200)
))
<div align="center"> <img src="man/figures/plotly-taglist.png" width="60%" /> </div>

Also, thanks to tagQuery(), it is fairly easy to query and manipulate the underlying HTML structure of components. See the tagQuery() article to learn more.

Learn more

If you're looking to learn how to build more custom user interfaces by writing custom HTML/JavaScript/CSS, we recommend the following resource: