Documenting my learning journey of Namaste React Live Course conducted by Akshay Saini
-
Native CSS - all components's styles in a single file index.css
-
SCSS - Syntactical CSS - it is then converted to css
-
Inline - style attribute - pass object - {{backgroundColor : "red"}}
-
Component Library - MaterialUI, Bootstrap, Base Web UI, Ant design, chakra UI
-
styled-components
-
CSS Framework - Tailwind
Steps to use tailwind css in app :
- Install tailwind css
npm install -D tailwindcss postcss
npx tailwindcss init
- Configure PostCSS
{
"plugins": {
"tailwindcss": {}
}
}
- Configure your template paths
module.exports = {
content: [
"./src/**/*.{html,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
- Add the Tailwind directives to your CSS
@tailwind base;
@tailwind components;
@tailwind utilities;
Content
The content section is where you configure the paths to all of your HTML templates, JS components, and any other files that contain Tailwind class names.
theme
We can customize color palette, spacing scale, typography scale, or breakpoints using theme section of your tailwind.config.js file
plugins The plugins section allows you to register plugins with Tailwind that can be used to generate extra utilities, components, base styles, or custom variants.
PostCSS is a CSS parser, framework or API that allows us to use plugins which can do various tasks. We use PostCSS because tailwind is installed as a PostCSS plugin.
While installing tailwind, install postcss as its peer dependency. Create a '.postcssrc' file in project root, and enable the tailwindcss plugin.
{
"plugins": {
"tailwindcss": {}
}
}