Home

Awesome

Tailwind Garden Clojars Project cljdoc badge

This library contains a copy of the CSS described by TailwindCSS documentation pages, ported to the Garden syntax.

The CSS was manually ported (copied and pasted + editor macros to convert syntax) and in case Tailwind changes, manual changes will be required to be done here as well.

That said, this doesn't have any dependency on any JS library, everything is self-contained here.

Using Tailwind Garden

To use all the Tailwind CSS:

(ns my-app
  (:require [com.wsscode.tailwind-garden.core :as tw]))

(def tailwind-css (tw/compute-css)) ; generate full css as string

Tailwind Garden is compatible with both Clojure and Clojurescript, in case you are making a web service and want to ship the CSS from it, you can just drop that string in some handler.

To use from Clojurescript, you can create a style tag and inject it:

(ns my-app
  (:require 
    [com.wsscode.tailwind-garden.core :as tw]
    [goog.dom :as gdom]))

(def tailwind-css (tw/compute-css))

(defn create-style-element [css]
  (doto (js/document.createElement "style")
    (gdom/appendChild (js/document.createTextNode css))))

(defn inject-css [css]
  (let [style (create-style-element css)]
    (gdom/appendChild js/document.head style)
    #(gdom/removeNode style)))

(defn main []
  ; on app mount, or whenever makes sense to inject the CSS
  (inject-css tailwind-css))

Customizing CSS

Currently, you can only choose to use or not specific components. In the future this library may provide detailed configuration of the variables.

A good way to start a custom build is to copy from the everything defined by Tailwind Garden.

Note you can also adjust the generated variants there.

Porting status

All the things ported! Or almost, still missing the variants for hover, active, etc...