CUBE CSS with Tailwind CSS
An example of how you can use Tailwind CSS as the U (utilities) in CUBE CSS. It also uses the following:
- Every Layout layouts as compositional layouts (the C in CUBE CSS)
- Utopia for fluid type and spacing scales
- Post CSS to bundle up CSS files
Why?
I work with clients that like to use Tailwind and I, as part of the consultancy work I do, try to encourage them down the path of a CSS methodology, rather than leaning all-in on a CSS framework.
Tailwind is fantastic at generating utility classes with an easy-to-understand config file, but I find it very limiting and rigid as the entire CSS codebase, so this project uses it how I would ideally use it: purely as the utility generator.
Consider this project diplomacy.
Getting started
- Run
npm install
- Run
npm start
to spin up a little local server and watch for CSS changes - Run
npm build
to compress CSS etc
Contributing
No thanks, but if you see something fundamentally wrong (not just your opinions, thanks), then let me know in the issues!
Handle color objects in Tailwind config
When this is useful:
Would produce CSS props like:
fix runtime error with partial-import plugin
postcss-partial-import throws an error during development because of an PostCSS major version bump, read about it here https://evilmartians.com/chronicles/postcss-8-plugin-migration
i did some digging and found, it seems like, the only one that is current
Use Tailwind's `resolveConfig` helper to load the final merged/resolved config
The recommended way of loading Tailwind config programmatically is to use the
resolveConfig
helper. The reason for this is that in most Tailwind setups, any customtheme
config is merged with a set of default config. If we justrequire
the config file directly then we will have access to the customtheme
config, but not to any of the default values.I realised after mentioning this to @hankchizljaw on Twitter that this isn't as useful as I thought it might be for this repo as the prototype creates a set of config items completely from scratch by providing an empty
presets
array in the Tailwind config, so there are no default values being used, just the values being explicitly set inside the Tailwind config file.Still, it doesn't hurt to load the config this way and it might be useful for others using this repo as an example, or if, in the future, a client removes the
presets
config item. As an example, this would let them create custom properties for theborderRadius
values provided by Tailwind's default theme, even if they didn't have a customisedborderRadius
object in their Tailwind config file'stheme
section.