Skip to content

Instantly share code, notes, and snippets.

@ian-moore
Created January 17, 2020 16:13
Show Gist options
  • Save ian-moore/39437c06106fa9f00fa65d7ea3bb084c to your computer and use it in GitHub Desktop.
Save ian-moore/39437c06106fa9f00fa65d7ea3bb084c to your computer and use it in GitHub Desktop.
use styled-components from npm with shadow-cljs and hx
  1. Install styled-components
npm install --save styled-components
  1. Require in your namespace
["styled-components" :default styled]
  1. Create a styled component
(def h1-template (styled "h1"))
(def red-h1 (h1-template [] "color: red"))
  1. Use as a hx component
(hx/f [red-h1 "cool"])
  1. Possible improvements
  • macro the template fn in step 3
  • accept clojure maps instead of string styles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment