Basecoat Assets
Description
Load the Basecoat stylesheet and scripts into a page. Files come from this package by default, or from jsDelivr.
Usage
bc_deps(
style = NULL,
js = FALSE,
theme = NULL,
source = c("local", "cdn"),
viewport = TRUE,
version = bc_version
)
Arguments
| Argument | Description |
|---|---|
style |
String or NULL. A style pack, one of vega, nova, maia, lyra, mira, luma, sera, rhea, or "base" for no visual style. NULL uses "vega". |
js |
Bool or character vector. Scripts to load. Defaults to FALSE, since components attach their own scripts. TRUE loads all of them, or name the ones to load. |
theme |
String or NULL. Path to a CSS file of your own, loaded after the style pack so its tokens win. See bc_theme(). |
source |
String. "local" (default) serves the bundled files. "cdn" serves the upstream files from jsDelivr, where several components render wrong. A URL prefix such as "/basecoat/" or "./basecoat/" points at a copy of the bundled files you serve yourself. |
viewport |
Bool. Add the mobile viewport setting to the page. Defaults to TRUE. |
version |
String. The basecoat-css release to serve. Only 1.0.2 is bundled, so any other release needs source = "cdn". |
Value
An htmltools::htmlDependency(), or a list of two when theme is given.
Details
Call once per page. Components attach their own scripts, so you need js only for hand-written HTML.
Load any other Tailwind build before this one, never after.
Serving the files yourself
Serve system.file("basecoat", package = "basecoat") under a path, then name that path as source.
plumber2::api_statics(api, at = "/basecoat/", path = system.file("basecoat", package = "basecoat"))
htmltools::renderDependencies(list(bc_deps(source = "/basecoat/")), "href")
Examples
bc_deps()
bc_deps(style = "maia", js = c("select", "toast"))
bc_deps(source = "cdn")
bc_deps(style = "lyra", source = "/basecoat/")
css <- tempfile(fileext = ".css")
writeLines(":root { --primary: oklch(0.54 0.16 320); }", css)
htmltools::attachDependencies(bc_button("Save"), bc_deps(theme = css))