Merge Tailwind CSS classes without style conflicts for Clojure(Script)
(require '[twmerge.core :as t])
;; Get the current time
(t/twmerge "w-xl w-[100px]") ;; => "w-[100px]"
(t/twmerge "px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]")
;; => hover:bg-dark-red p-3 bg-[#B91C1C]
- Supports Tailwind v3.0 up to v3.4
- Works in all modern browsers and JVM env
To include one of the above libraries, for instance ring-core
, add
the following dependency to your deps.edn
file:
com.shipclojure/tailwind-merge-clj {:mvn/version "0.1.0"}
Or to your Leiningen project file:
[com.shipclojure/tailwind-merge-clj "0.1.0"]
The package is available on Clojars)
Works both on clojure & clojurescript runtimes so it can be used to SSR from JVM with a tool like Uix
See tests
See Original's library doc for what it is for
Full credit for the implementation goes to the Original Tailwind Merge and the author Dany Castillo.
This is a rewrite of the same implementation logic in cljc
to better support server side rendering from JVM.
Copyright © 2024 Ovistoica
EPLv1.0 is just the default for projects generated by clj-new
: you are not
required to open source this project, nor are you required to use EPLv1.0!
Feel free to remove or change the LICENSE
file and remove or update this
section of the README.md
file!
Distributed under the Eclipse Public License version 1.0.