Tailwind

unpublished draft
ReactJsTailwind

Overview#

Tailwind was created and primary focusing on css part. That make it much more faster than others css-in-js frontend framework. But that also mean it is lower level, and might not be the best for quick release cycle project and performance favor.

General ideas#

There are 3 main parts of the lib:

Customization#

Setup#

Using Next.Js. Plain react projects was not likely need to perf that tailwind offer (along with all the overhead of re-build many things with it). Detail installation can be found here

For moduling tailwind:

yarn add postcss-import -D
# For sass support
yarn add sass postcss-import -D
postcss.config.js
module.exports = {
  plugins: {
    'postcss-import': {},
    tailwindcss: {},
    autoprefixer: {},
  },
};

// For sass support
module.exports = {
  plugins: {
    'postcss-import': {},
    'tailwindcss/nesting': {},
    tailwindcss: {},
    autoprefixer: {},
  },
};

Personal optinate#

Cascading... or scope ?#

From the point of backend-heavy point of view. I was more favor of scope css process (which might refer as css modules). This ensure postfix all module class name with somethign to make it unique, therefore their styles was scoped and not cascade down to other component. This was so nice for many others library which have their own custom - ready to use components, and those whose doesn't want to mess with the cascade things.

But things might change quite a bit with tailwind, which primary focus on css part. So, in order to harvest that power, we need somehow make a compromise with the idea behind it. Ofcourse, css modules would work, but why not drill a little deepper to gain something more cool that the framework offer ?

That bring naming convention back to top, and BEM naming convention might help us solve just exactly that.


Khanh Nguyen

Web developer & .Net lover