package tw
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=198a142b69828a53a0c8812b70f279be6c216b411b370c3433d5fe94be5d495e
sha512=fe0a94ef1ff22e19c669d4370c6b555bf323053e05a8cfc315196beb312703f68ec62966b2b7780b6a79c2e8db88e8aa816d7fe3cb3a2044e6f52ed4d839a3b4
doc/tw.dom/Tw_dom/index.html
Module Tw_domSource
Client-side CSS injection for js_of_ocaml apps.
Manages a single <style> element in the document head. Utilities are registered at runtime and their CSS is injected into the DOM. The style element grows monotonically — utilities are never removed.
Usage with Helix:
let init_tw_dom () = Tw_dom.init ()
let card_class () = Tw_dom.use Tw.[ flex; p 4; bg blue; rounded_lg ]Usage standalone:
let app_class () = Tw_dom.use Tw.[ flex; p 4 ]init ?base () initializes the style injection system. Creates a <style> element in the document head. If base is true (the default), the Tailwind base/preflight layer is included. Call once at application startup.
use styles registers the given utilities and returns a space-separated class name string. New CSS rules are injected into the DOM immediately. Already-registered utilities are not re-injected.
use_str s parses a space-separated Tailwind class string, registers the utilities, and returns the class name string. Raises Invalid_argument if any class is not recognized.
css () returns the current accumulated CSS as a string.