compile_tailwindcss: Starts the 'TailwindCSS' CLI

View source: R/tailwind_cli.R

compile_tailwindcssR Documentation

Starts the 'TailwindCSS' CLI

Description

See v4 docs or v3 docs.

Usage

compile_tailwindcss(
  infile,
  outfile,
  version = 4,
  config = "tailwind.config.js",
  watch = FALSE,
  minify = FALSE,
  content = ".",
  tailwindcss = NULL,
  verbose = FALSE
)

Arguments

infile

the 'TailwindCSS' file (eg containing the ⁠@tailwind⁠ directives). Relative to basedir

outfile

the target css file, where tailwind will write the css to. Relative to basedir

version

Which version of tailwind to use. Default is now v4.

config

the path to the tailwind.config.js file. With v4, the config file is not needed and can instead be specified in the infile css. With v3, the default is tailwind.config.js in the root diretory.

watch

if the files should be continuously monitored (versus only compile the css once), default is False

minify

if the code should be minified, default is FALSE

content

content paths to remove unused classes, default is current dir

tailwindcss

name and path to the executable

verbose

print information

Value

the outfile invisibly

See Also

install_tailwindcss_cli

Examples

if (interactive()) {
  temp <- tempdir()
  owd <- setwd(temp)

  infile <- "custom.css"
  writeLines("@tailwind base;", infile)
  outfile <- "out.css"

  # file.copy(system.file("examples", "01-Old_Faithful", "app.R", package = "shiny.tailwind"),
  #           "app.R", overwrite = TRUE)

  # write a mini shiny UI
  writeLines("
    library(shiny)
    div(class = \"page-div\",
        div(class = \"w-full text-center py-12\",
            h1(\"Hello World\")
        )
    )", "app.R")

  tailwindcss <- NULL # can be set to the executable file
  compile_tailwindcss(infile, outfile, tailwindcss = tailwindcss)
  cat(paste(readLines(outfile)[1:20], collapse = "\n"))

  setwd(owd)
}

kylebutts/shiny.tailwind documentation built on April 17, 2025, 5:21 p.m.