This repository is for tracking the learning curve of tailwindCSS. Here I will design my CV as a 2nd training project of DSi.
Live Repo Link: Click here
Few Learning links I used:
Tailwind
we need to combine rounded
, shadow
, p-2
, bg-white
classes. So our code will be class="rounded shadow p-2 bg-white"
.
This doesn't mean we have to do more work than bootstrap btw.Install Tailwind using node package manager. So we will ned node.js installed in our computer.
Steps:
sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt -y install nodejs
node -v
npm init -y
. We need this to track our installed dependencies.tailwind
, postcss
, autoprefixer
dependencies using npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
base
, components
, and utilities
styles:@tailwind base;
@tailwind components;
@tailwind utilities;
"build-css": "npx tailwindcss-cli@latest build ./src/styles.css -o ./public/styles.css"
npm run build-css
which will build tailwind necessary utility classes.Any changes made inside src/styles.css will be updated public/styles.css.
Installing live server globally and live the public folder only.
sudo npm install live-server -g
live-server public
Without any CSS we are viewing default browser styles. So to link public/styles.css
we will use link
tag inside public/index.html
. After adding css our whole design becomes same as we didn't define any utility class so far.
We can extend a property or overwrite the default one.
npx tailwind@latest init
or full version with default values npx tailwind@latest init -full
.npm run build-css
.Tailwind is a mobile-first approach. It starts with the smallest possible device.
If we have same classes which need to write again and again we can use our custom class and apply the directives.
.<custom name> {
@apply <all the classes here>;
}
Then instead of writing all the classes, just use <custom name>
.
So far, tailwind didn't cover pseudo elements like ::before
and ::after
. Issues opend in Tailwind Github Repo. But there are few plugins by which we can use them Link1, Link2.
npm i tailwindcss-pseudo
npm install tailwindcss-pseudo-elements --save-dev