Learning tailwind fundamentals
Tailwind
Motto: Rapidly build modern websites without ever leaving your HTML. Usage: A utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
Advantages:
- An API for your design system: easy to be consistent
- Because Tailwind is so low-level, it never encourages you to design the same site twice.
- Tailwind automatically removes all unused CSS when building for production, which means your final CSS bundle is the smallest it could possibly be.
- Mobile first, Responsive everything.
- Hover and focus states? They got ’em.
- Component-driven: Worried about duplication? Don’t be.
- Built in dark mode
- Customize everything inside tailwind.config.js
- The Tailwind CSS IntelliSense extension for VS Code has you covered.
- Ready-made components (Expensive)
Common knowledge
- Size:1rem = 16px, 1.125rem = 18px, 1.5rem = 24px
- Scale xs, sm, base, lg, xl, 2xl, 3xl, ..., 9xl
- Arbitrary values: text-[14px]
- Single side: {t|r|b|l,x,y,none}-{size} top, right, bottom, left, horizontal, vertical, all sides
- Negative value:
-mt-8prefix the class name with a dash - Tailwind scale: 1 is 0.25rem. ex: m-1
- Responsive design: sm:640px, md:768px lg:1024px, xl:1280px, 2xl:1536px,
md:w-32: width is 32 for all screen size higher than 768px. Default value for others
Common classNames
- font-size
- text-base: font-size: 1rem, line-height: 1.5rem.
- Other values: text-xl etc
- Setting the custom line-height:
text-base/loose,
- Line height
- leading-normal: line-height: 1.5; leading-relaxed line-height: 1.625;
