(defstyles name)(defstyles name path)Loads CSS file at compile time and returns either a CSSStyleSheet object (if supported) or a string fallback.
Options: :with-vars? - If true, automatically prepends CSS variable inheritance
Usage: (defstyles button-styles) ; looks for button.css in same dir (defstyles button-styles "custom.css") ; custom path
The macro will:
Loads CSS file at compile time and returns either a CSSStyleSheet object (if supported) or a string fallback. Options: :with-vars? - If true, automatically prepends CSS variable inheritance Usage: (defstyles button-styles) ; looks for button.css in same dir (defstyles button-styles "custom.css") ; custom path The macro will: 1. Load CSS file content at compile time 2. Optionally prepend CSS variable inheritance 3. At runtime, create CSSStyleSheet if supported 4. Otherwise return the CSS string for fallback
(ensure-styles! shadow-root styles)(ensure-styles! shadow-root styles style-id)Applies styles to a shadow root, handling both CSSStyleSheet and string styles. Prevents duplicate style application.
Arguments:
For CSSStyleSheet:
For string styles:
Applies styles to a shadow root, handling both CSSStyleSheet and string styles. Prevents duplicate style application. Arguments: - shadow-root: The shadow DOM root element - styles: Either a CSSStyleSheet object or CSS string (from defstyles) - style-id: Unique identifier to prevent duplicates (optional) For CSSStyleSheet: - Adds to adoptedStyleSheets if not already present For string styles: - Creates a <style> element with the given ID - Only adds if no style with that ID exists
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |