Giter VIP home page Giter VIP logo

tailwind-hiccup's Introduction

Clojars Project

tailwind-hiccup

tailwindcss + hiccup = ๐Ÿ‘๐Ÿ‘.

Rationale

By its nature, a functional/atomic/utility class approach to CSS like Tailwindcss turns out to be pretty pleasant to use with Hiccup-based ClojureScript front-ends like Reagent or Rum, or server-side Hiccup templates.

Styling becomes a matter of composing from a standard library of utility classes. Since they're just data, we can keep them in collections, give them names, conj them together, etc.

Better still on the front-end side: the dead-JavaScript-elimination available through advanced ClojureScript compilation sets up for impressive dead-CSS- elimination performance from PurgeCSS. Any Tailwind class name strings present in unused components will have been dropped from the JS bundle along with the component, so the Google Closure compiler is doing most of the work of figuring out which components could ever be used at runtime.

Getting started

Add tailwind-hiccup as a dependency, eg. for tools.deps projects

;; deps.edn
{:paths [,,,]
 :deps {,,, rgm/tailwind-hiccup {:mvn/version "0.2.0"} ,,,}

Setting up the css build can be a little complex. See the basic usage example.

API

Inspired by stylefy.core/use-style, this library provides a function tw that gives a easy-to-spot way to snap together collections of utility classes in Hiccup props:

(require '[tailwind-hiccup.core :refer [tw]]

(def color-transition [:transition-colors :ease-in-out])
(def short-duration [:duration-300])
(def hover-colors ["hover:text-white" "hover:bg-red-500"])

(defn MyButton
  [button-text]
  [:button.a-non-tw-class
   (tw [:mx-3 :my-4 :font-bold]
       hover-colors
       color-transition short-duration
       {:on-click #(js/alert "surprise!")})
   button-text])

tailwind-hiccup's People

Contributors

dependabot[bot] avatar rgm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rkx-forks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.