Essential CSS
JavaScript Roadmap
Learn JavaScript
Mastering Web Typography
Practical Astro
Understanding Async JS
Unorthodox Tailwind
API Masterclass
Build and Deploy
The Beginner Freelancer
Real World Node
Profile Billing Logout
Build and Deploy
Lesson Plan
  1. Workshop Recordings
    1. Welcome to Build and Deploy!
    2. Important notes before you begin
    3. 📹 Session 1
    4. 📹 Session 2
    5. 📹 Session 3
    6. 📹 Session 4
    7. 📹 Session 5
    8. 📹 Session 6
    9. 📹 Session 7
    10. 📹 Session 8
    11. Next steps

📹 Session 2

1m:9s
30m:56s

Styling is important since it makes websites and components look nice 🙂.

In this session you’re going to learn how to style with Astro.

You’ll learn about:

  • Scoped styles
  • Global styles
  • Using CSS
  • Using Sass
  • Using PostCSS
Note

In the video, I talked about using PostCSS instead of Sass.

Well, after even more experimentation, I changed my mind again and switched back to Sass. I have reasons for this but I won’t be detailing them in this short note here.

Source Code

Here’s a link to the Github repository

Timestamp

  • 0:00 Introduction
  • 8:00 Recap of the last session
  • 12:30 Two ways to write CSS in Astro
  • 14:00 Scoped styles
  • 15:45 Global styles
  • 19:30 Building styles
  • 21:15 Importing CSS
  • 22:30 Using Sass
  • 28:10 Component vs Global styles
  • 31:30 Using PostCSS instead of Sass
  • 38:00 PostCSS only vs PostCSS and Sass
  • 44:45 Styling components
  • 49:22 Screw the best practices! 🙃
  • 50:00 Questions and Answers

Further Notes

You may run into frustrations if you’re styling components with JavaScript enabled. (These components have a client directive on them).

You’ll learn about client directives later in the series.

But for now, if you ran into styling issues with them, check out this article that I wrote.