Stop shimming/observing all nodes.
Configure the default tw and starts observing the
target element (default: document.documentElement
).
You do not need to call this method. As an alternativ you can provide a
<script type="twind-config">...</script>
element within the document.
The content must be valid JSON and all twind setup options
(including hash) are supported.
Generated using TypeDoc
The
twind/shim
module allows for the use of theclass
attribute for tailwind rules. If such a rule is detected, the corresponding CSS rule is created and injected into the stylesheet dynamically.twind/shim
is intended for client-side usage and, without configuration, utilizes the default/global tw instance. For server-side usage, twind/shim/server exports a dedicated shim function that will parse and update a static HTML string while collecting the style rules into a sheet for further usage in your respective framework.There is no need for
tw
but it can be used on the same elements as well. All Twind syntax features like grouping are supported within class attributes. See example/shim.html for a full example.tw
instanceUsage
For runtime processing of your javascript-assisted HTML documents, simply include the
twind/shim
module and watch the magic happen.The
twind/shim
module utilizes the twind/observe module internally, but it provides its own setup function for customizing the used tw instance and setting the target node to be shimmed. It also provides a disconnect function to stop shimming/observing all nodes.Customize
tw
instanceYou can provide a
<script type="twind-config">...</script>
within the document. The content must be valid JSON and all twind setup options (including hash) are supported.Alternatively the following works:
It is possible to mix
twind/shim
with tw:Prevent FOUC (flash of unstyled content)
To prevent FOUC (flash of unstyled content) it is advised to set the
hidden
attribute on the target element.twind/shim
will remove it once all styles have been generated.FAQ
How can I use twind/shim from javascript?
How to support legacy browser with the UMD bundles?
How does the shim work?
twind/shim
starts {@link twind/observe.observer | observing} class attributes changes right after the DOM content has been loaded. For further details see twind/observe.