pota/use/csspota/use/css ships the building blocks for constructable
stylesheets: a tagged-template css and a cached sheet(string)
factory that both return a CSSStyleSheet, plus document /
shadow-root adoptedStyleSheets helpers. This is the low-level
surface the css / use:css prop is built on.
css — tagged-template wrapper over String.raw (documented below)sheet(string) — cached CSSStyleSheet factoryCSSStyleSheet — the global constructor,
re-exportedgetAdoptedStyleSheets(doc) — a
document / shadow root's adoptedStyleSheetsadoptedStyleSheets — the main
document's adoptedStyleSheets, pre-boundaddAdoptedStyleSheet(doc, sheet)
— idempotent addremoveAdoptedStyleSheet(doc, sheet)
— removeaddStyleSheets(doc, sheets) — add a
mixed array of sheets, CSS strings, and URLsaddStyleSheetExternal(doc, urlOrText)
— single fetch-or-parse addBuilds a CSSStyleSheet from a tagged template. css is a thin
wrapper over String.raw that calls sheet(); the
tag exists so editors that recognise css`...` highlight your
styles. Adopt the result with
addAdoptedStyleSheet.
import { css, addAdoptedStyleSheet } from 'pota/use/css'
const styles = css`
:host {
display: block;
}
button {
color: tomato;
}
`
addAdoptedStyleSheet(document, styles)