pota/use/css

pota/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.

Exports

Examples

Tagged-template css

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