How I'm Writing CSS in 2024

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ส.ค. 2024

ความคิดเห็น • 126

  • @JamesMoyle_3p
    @JamesMoyle_3p 7 หลายเดือนก่อน +9

    I'm glad you started this with raw CSS, and how to use it in a real world scenario with lightning. Showing how CSS can be done without JS build systems or typescript

  • @anthonygayflor
    @anthonygayflor 7 หลายเดือนก่อน +13

    Thank you for always being so active in the community.

    • @leerob
      @leerob  7 หลายเดือนก่อน +4

      🖤

  • @VeitLehmann
    @VeitLehmann 7 หลายเดือนก่อน +3

    Nice overview! I think those three are probably the best options today. I'm still mostly using CSS modules as they solve most of the past headaches, but I'm also looking into Tailwind and StyleX.
    CSS modules solve the naming collision problem of plain CSS, and with colocation with the components, they make it easy to get rid of unused styles. Drawbacks: you still have to come up with names, and it you're building a shared ui library with it, you will always ship the CSS for all modules, even when consumers only use some.
    Tailwind makes it easy to get started quickly: By shipping a nice design token system, you are likely to get consistent styling without much effort. You also don't have to name classes. And with extreme colocating, it helps with code reviews. Drawbacks: convoluted JSX code, and getting overridable styles right (often needed for shared ui libraries) is not easy. Also, you lose access to a lot of CSS features, and you have to learn the system, but to use Tailwind effectively, you still need to know CSS to choose the best layout approaches.
    StyleX is more complex to begin with. But it really seems to be made with shared ui libraries in mind! In contrast to past solutions in its family, you get fine-grained control over how ui library consumers can override component styles, along with type safety. Drawbacks: I personally don't like writing CSS rules in JS objects, there's quite a bit of boilerplate code needed, and you still have to name things like with CSS modules.
    So, in conclusion, all three are great. CSS modules are great if you know CSS and want access to all its features without getting lost in naming conventions. Tailwind is great to get started quickly with standalone projects, and StyleX is awesome for use in different projects with a shared ui library.

  • @goodboytech
    @goodboytech 7 หลายเดือนก่อน +28

    CSS modules is just so simple and perfect

    • @rand0mtv660
      @rand0mtv660 7 หลายเดือนก่อน +9

      I personally really like CSS Modules, but they aren't perfect. I've been using them for last couple of years, but recently switched to Tailwind and I think I'm not going back.

    • @axlYT
      @axlYT 7 หลายเดือนก่อน

      @@rand0mtv660same

    • @axlYT
      @axlYT 7 หลายเดือนก่อน

      @@rand0mtv660after all this css and scss modules i tried tailwind and was amazed by it. 99% of the arguments people use against it they don’t really understand the right way to using it. If u use something like React its just perfect for now

    • @darshandhabale143
      @darshandhabale143 7 หลายเดือนก่อน

      @@rand0mtv660 what are the issues you faced with them that tailwind solved

    • @aberba
      @aberba 7 หลายเดือนก่อน

      ​@@rand0mtv660 what was your issue with it?

  • @aryankathawale9269
    @aryankathawale9269 7 หลายเดือนก่อน +13

    Hey lee, preety cool stuff , i would love to have an indepth overview on Metadata api introduced with app router , specifically the og stuff and twitter images , best practices , ps: love this video , love you , thanks for amazing content

    • @leerob
      @leerob  7 หลายเดือนก่อน +1

      Good idea!

    • @maxwebstudio
      @maxwebstudio 7 หลายเดือนก่อน

      Oh that's a pain !

  • @WebDevCody
    @WebDevCody 7 หลายเดือนก่อน +132

    tailwind gang, comment with a "woot woot"

    • @learntechbasics
      @learntechbasics 7 หลายเดือนก่อน +2

      Woot Woot 😂

    • @harsh_9797
      @harsh_9797 7 หลายเดือนก่อน +1

      Woot woot 😅

    • @itsyourboyt4683
      @itsyourboyt4683 7 หลายเดือนก่อน +1

      woot woot

    • @DestinoDello
      @DestinoDello 7 หลายเดือนก่อน +1

      woot woot

    • @rishabh1S
      @rishabh1S 7 หลายเดือนก่อน +1

      Woot Woot 😂

  • @JamesQQuick
    @JamesQQuick 7 หลายเดือนก่อน

    Great content as always!

  • @RiyaBiswas-pq1xo
    @RiyaBiswas-pq1xo 5 หลายเดือนก่อน

    I really liked how you explained things, specially your storytelling style

  • @lcarv20
    @lcarv20 7 หลายเดือนก่อน +2

    Love the vid, one thing I hate about stylex (besides the name), is that you have to use the spreads a lot, which, IMO, makes the code unpleasant to read. With tailwind people can always create variables that express the intent or wrap everything in a single class.

  • @dannylake1968
    @dannylake1968 7 หลายเดือนก่อน

    Styling engines built with a static / build time css-in-js architecture, like stylex or panda-css, is a generational leap ahead of tailwind. They provide the developer experience of css-in-js and remove the bundle cost and runtime in browser tradeoffs. UI libraries that build on top of these types of styling engines will be the new hotness in 1-2 years.

  • @madebyjonny7637
    @madebyjonny7637 7 หลายเดือนก่อน +1

    Great video. Only part I think was missing would be if you were to go beyond simple styles into design systems & style variants, as Tailwind does start to resemble StyleX when you want to have variants

    • @leerob
      @leerob  7 หลายเดือนก่อน

      Yeah, StyleX seems really powerful here. Agreed.

  • @hichemfantar1965
    @hichemfantar1965 7 หลายเดือนก่อน +3

    Another great plugin I use is Tailwind Typography, I use it after tailwind resets all the css. it allows me to achieve consistent typography across the entire app and different browsers without additional setup on my end. And the cool thing is that I can opt in/out at anytime with the prose classname. I have it on by default and disable when I need to.
    The plugin was initially created for html that's coming from external sources but I find it really good in my mentioned use case as well.

  • @mateus.duraes
    @mateus.duraes 7 หลายเดือนก่อน

    What an amazing video, thanks Lee

  • @sethwright2518
    @sethwright2518 7 หลายเดือนก่อน

    I've been in Tailwind camp for a while now.. but StyleX looks like a really strong alternative

  • @deatho0ne587
    @deatho0ne587 7 หลายเดือนก่อน +1

    StyleX and Astro seem similiar.
    One of the things I hated about pre-2010 web was inline styles, which I still dislike and Tailwind basicaly is that. Just instead of writing style="..." it is class/className="".

  • @SunAndMoon-zc9vd
    @SunAndMoon-zc9vd 16 วันที่ผ่านมา

    Why would you not use the CDN for production code? Ref. the part at about 8:20 about Tailwind CSS.

  • @TrackingAcademy
    @TrackingAcademy 7 หลายเดือนก่อน

    Thank you, always for amazing content

  • @user-ik7rp8qz5g
    @user-ik7rp8qz5g 7 หลายเดือนก่อน

    One issue I get with css modules (at least in react/next projects) is critical chain warning. Always huge when using modules for all pages and components

  • @capricik
    @capricik 7 หลายเดือนก่อน +1

    How i'm writing css:
    "hey chatgpt, what's the code to give my text a Red background?"

  • @loquek
    @loquek 7 หลายเดือนก่อน +1

    Panda/CVA is looking super strong

  • @marclamy9997
    @marclamy9997 7 หลายเดือนก่อน

    I love your videos Lee but could you change the cam video placement? it's often above the content you're showing and talking about 😅

  • @AlwafiCharki
    @AlwafiCharki 7 หลายเดือนก่อน +2

    I want to ask for you advice 🙏
    I am now at point that i can work very well with css and can say i understood mostly everything , but i have no idea of boostraps and that tailwind thing and the other things , i want your advice what should i do next ? (My ultimate goal is to make amazing websites that is responisive)

    • @HumanoAI
      @HumanoAI 7 หลายเดือนก่อน +2

      Learn css html and js then have the AI help you code extensive functions and the back end. You must know how to communicate with the AI in describing what you need. Without terms and some understanding of how things work you won’t be able to use AI to resolve. If you learn frameworks you will always be a T the mercy of those frameworks, there is a pro and con. Getting up to speed is very frustrating as breakage happens. I think AI is stunning frameworks, reason being is you can have AI create only the js needed, avoiding all the extra code that goes unused.

    • @otto3225
      @otto3225 7 หลายเดือนก่อน +1

      That's perfect, knowing CSS is always an advantage over knowing a framework. You can build everything you want with pure CSS and it has great features to make your websites responsive and you can easily debug it with dev tools in your browser.
      Frameworks come and go like trends come and go. Maybe in 3 or 5 years everyone says, "get rid of tailwind, it's the biggest crap we ever made 😂" ... and i'm pretty sure that day will come, like it came for other super trendy trends.
      CSS will still be there and it will have even more amazing features than it has now 😉

    • @AlwafiCharki
      @AlwafiCharki 7 หลายเดือนก่อน

      @@HumanoAI very eye opening thank you very much🙏🙏

    • @AlwafiCharki
      @AlwafiCharki 7 หลายเดือนก่อน

      @@otto3225 this what i though too , right now i am taking lessons in boostrap , and i cant stand it specially that i can do everything it does with pure css , but now i need to remmber the names of classes just why lol
      But just as you said as lobg i understand the core which is css , i can adjust with time

  • @DoraTheExplorer-lu2in
    @DoraTheExplorer-lu2in 7 หลายเดือนก่อน

    Generated by Merlin AI
    00:02 CSS is easier and more powerful with new features.
    01:46 Write maintainable CSS with good developer experience
    03:19 CSS queries allow for dynamic styling without additional tooling
    04:52 Streaming CSS is important for on-demand styling.
    06:35 CSS modules and Tailwind CSS are popular options for styling in 2024.
    08:17 Tailwind CSS allows for generating a CSS file based on used class names.
    09:47 StyleX is a zero-runtime CSS and JS solution.
    11:27 CSS in 2024 offers easier styling with improved tooling and cross-framework support.

  • @dukeselwood
    @dukeselwood 5 หลายเดือนก่อน

    StyleX isn't compatible with NextJs 🙁

  • @jellyfish1772
    @jellyfish1772 7 หลายเดือนก่อน

    this is a cool video.thanks!

  • @adamthesoftwareengineer
    @adamthesoftwareengineer 7 หลายเดือนก่อน

    Hey Lee, nice video! I got a question related to Next tho. Is it fine if I store my reusable components or services (functions I use to retrieve data from my DB) in folders that are prefixed by _ in my app directory? Or can this practice potentially impose routing performance issues if they get heavy? Thanks in advance!

  • @KuroKazeZX
    @KuroKazeZX 7 หลายเดือนก่อน +1

    irdk who stylex is for, because even lets say a brand wants to make the style consistent accross platform, its simply too much busiwork to implement some additional basic styling for the consumer, which is far easier to write and read with tw

    • @TheBswan
      @TheBswan 7 หลายเดือนก่อน +1

      Not everyone wants to learn all the tailwind shorthand, have long class strings in their markup, and bring in additional libraries like cva for variants. StyleX has a minimal API surface area, so if you know CSS you can learn StyleX in 10-20 minutes. I'm not necessarily sold one way or the other; just two different approaches with different tradeoffs.

    • @KuroKazeZX
      @KuroKazeZX 7 หลายเดือนก่อน

      @@TheBswan thats fair actually, if you had to pick one poison stylex might be easier to down for the uninitiated.
      i think longer term, tw is faster to pick and iterate with, but yeah if tailwind is discontinued then that's a lost knowledge.
      btw, i agree, cva and tw-merge should be built in to tailwind.
      that said, i think inline styles, as long as it makes "class", is more readable and configurable than ...someStylex.
      but preference pretty much.

  • @yondoy987
    @yondoy987 6 หลายเดือนก่อน

    styled-components is the best for me

  • @ThanHtutZaw3
    @ThanHtutZaw3 7 หลายเดือนก่อน

    I can't check css module import error with next lint .

  • @officiallydheeraj
    @officiallydheeraj 7 หลายเดือนก่อน +1

    You didn't mention Panda CSS. I wonder why

    • @leerob
      @leerob  7 หลายเดือนก่อน

      Panda looks interesting as well!

  • @LutherDePapier
    @LutherDePapier 7 หลายเดือนก่อน

    What's the font you're using in your VS Code ?
    Edit: My bad, I just realized it's CodeSandbox.

  • @Jason-mk3nn
    @Jason-mk3nn 7 หลายเดือนก่อน

    5. No popups, unless critically essential to the end user. The popup on blur should be penalized.

  • @lukasmolcic5143
    @lukasmolcic5143 7 หลายเดือนก่อน +1

    Can Next please allow loading non .module .css and .scss files in to components, Next can handle the loading and leave the worrying about name collisions to me, I want to have non hashed class names which I when needed can reference contextually in other files and I don't want to always load those styles globally which is the only option next provides.

    • @theReal_WKD
      @theReal_WKD 7 หลายเดือนก่อน

      I'm not sure if I fully understand what's your issue but do you know that you can create css/scss file and import them inside a specific component file? It essentially works like a module.css. It gets imported only when the corresponding component is used, and you get to keep clean class names.
      The only diff would be that these classes, once loaded by there component will be accessible by the whole page and not just scoped to that component like with module.css.
      Actually, using module doesn't scope the classes for a specific component, it just uses hashed class names so no matter how you named it in your file, it will end up as hashed to avoid conflict with a class named identically in another module that would happen to be loaded on the same page.

  • @Nightizm
    @Nightizm 7 หลายเดือนก่อน

    I think my ideal would be using Tailwinds design system along w/ a StyleX alternative like PandaCSS

    • @SCK-47
      @SCK-47 7 หลายเดือนก่อน

      why do you need stylex what does it give that you need along side tailwind? I am currently using MUI and I want to switch to Tailwind but stylex is very like MUI so I am torn

    • @Nightizm
      @Nightizm 7 หลายเดือนก่อน

      @@SCK-47 I like writing styles, it's a personal preference. I'm just saying I really like Tailwinds robust Design System with spacing, colouring, etc, but hate actually using Tailwind. So I'd much rather start a fresh project using their design system but writing my own styles with a zero runtime CSS-in-JS tool.
      Also MUI is a component library and stylex is not, I wouldn't be comparing them.

  • @germantoenglish898
    @germantoenglish898 6 หลายเดือนก่อน

    Working at Next.js must be cool.

  • @MaxWeir
    @MaxWeir 7 หลายเดือนก่อน

    Is there any advantage to having css variables for more than just colour? We currently only use them for colour but I’ve seen other sites that use them in greater detail.

    • @UTube-nigga
      @UTube-nigga 6 หลายเดือนก่อน

      Font sizes? Padding? Margins?

  • @newbielife1
    @newbielife1 7 หลายเดือนก่อน +1

    is styled-components dead?

    • @coherentpanda7115
      @coherentpanda7115 7 หลายเดือนก่อน

      Dead? It gets updates nearly every week, and still just behind Tailwind on the popularity chart.

  • @TomRadic
    @TomRadic 7 หลายเดือนก่อน

    Is it bad practise using Tailwind css with modules?
    I am using @apply with "tailwindcss/nesting": "postcss-nesting",

    • @bn5055
      @bn5055 7 หลายเดือนก่อน

      You should avoid using @apply unless absolutely necessary. If your css is in a separate file, you're doing it at least a little wrong 😊

  • @samoart
    @samoart 7 หลายเดือนก่อน +2

    panda css ❤

  • @nomadshiba
    @nomadshiba 6 หลายเดือนก่อน

    really love this new css @scope
    foo
    @scope {
    :scope {
    background-color: red;
    }
    .foo {
    background-color: blue;
    }
    }
    also big fan of
    Name
    .card {
    --my-special: "card"
    }
    @container style(--my-special: "card"){
    .name {
    color: red;
    }
    }

  • @rand0mtv660
    @rand0mtv660 7 หลายเดือนก่อน

    11:20 I dislike most css in js solution, but this is at least more readable and clear compared to something like styled-components where every little style is a component so you always jump back an forth to see what's going on, plus that styles can compose from other components etc. To me personally, it was one of the worst experiences I had writing CSS.

    • @dealloc
      @dealloc 7 หลายเดือนก่อน +1

      Styled components can be done with different APIs and is not limited to only create components from styles. It's useful for creating reusable wrapper components for default styles, like buttons, etc. which forwards all props from a base html tag.
      Another example is Stitches which allows you to define variants and expose those as props (rather than exposing arbitrary CSS attributes as props). It scales the same as StyleX, because each CSS attribute + value becomes its own class, so it scales linearly.
      As with other styled-component like APIs it also exposes a `css` function which can be used for creating class names from styles, like StyleX' API.
      So the only difference API-wise is that StyleX doens't allow cascading and doesn't provide an API to create wrapper components.

    • @rand0mtv660
      @rand0mtv660 7 หลายเดือนก่อน

      @@dealloc how is that base/default component different compared to using a stylex defined style here that you just put as first and those are your base styles and then you add a prop called "variant" for example to expose different variants of that component?
      I mean, maybe I didn't explore styled-components fully, but everything I had contact with when working with SCs was just a horrible experience.
      I respect that many people might like them, but I'm not one of those.

    • @dealloc
      @dealloc 7 หลายเดือนก่อน

      @@rand0mtv660 I wasn't talking about styled-components (the library) specifically, but Stitches which is/was another "styled" component library. It has its own problems-e.g. passing props can end up duplicating CSS at runtime.
      In Stitches (and APIs like it) you get a nicer API around defining variants with zero logic, and produces deduplicated styles, since they utilize CSS variables (for tokens) and generates class per attribute.
      For variants you just define an object with keys that are the prop names, which defines an object of values mapped to the style they represent. These are then exposed on the resulting React component.
      For example say you have a Button component and you add 2 variants, one "kind" where its values can be a string of "confirm" | "destructive" | "default", each defining their own style, extending from and can override from) the base style, and another that maps a boolean value (e.g. true) to specify an outlined style.
      You can choose to either use CSS variables directly (using var(--... syntax)), or create compound variants to create the combination of variants so they can be used with different permutations of those variants.
      The point here is that styled components doesn't have to be limited to only creating components from CSS with custom handling of passed props using template strings.

  • @WebsiteDevelopment-Uk
    @WebsiteDevelopment-Uk 7 หลายเดือนก่อน

    I personally don't like Stylex as it can get very confusing.

  • @goldroger6374
    @goldroger6374 6 หลายเดือนก่อน +1

    styled components go brrrrr

  • @w00t360
    @w00t360 7 หลายเดือนก่อน +2

    I've been in the web industry for over 15 years. I went from Bootstrap to Tailwind. Haven't written a single CSS line of code since. And like Lee said, coming back 2-3 years later you'll immediatelly recognize the APIs, text-sm, font-semibold etc. I'm never going back to writing CSS ever again!

  • @IkraamDev
    @IkraamDev 7 หลายเดือนก่อน

    I prefer to use Tailwind or Styled Components.

  • @mattwebbertime
    @mattwebbertime 6 หลายเดือนก่อน

    5:50 - "NFL"

  • @kasper_573
    @kasper_573 7 หลายเดือนก่อน

    Vanilla extraaaact

  • @mikehurtado4772
    @mikehurtado4772 7 หลายเดือนก่อน

    Pues igual que antes, con el teclado

  • @aberba
    @aberba 7 หลายเดือนก่อน +1

    stylex is overengineered just like most things from those companies

    • @VeitLehmann
      @VeitLehmann 7 หลายเดือนก่อน

      Looks like it's made to build a shared ui library and using that across different projects. That's where it shines because you can define how component styles can be overridden by ui lib consumers in a much more granular way than ever before. For standalone projects, it's likely to be overkill.

  • @okopyl
    @okopyl 7 หลายเดือนก่อน

    The same as in 2023, so change the title of the video so it's not misleading

  • @iAmTheWagon
    @iAmTheWagon 7 หลายเดือนก่อน +2

    tailwind-variants

  • @codokit
    @codokit 7 หลายเดือนก่อน

    Traditional CSS has much less issues than CSS in JS, Less/SASS. Tailwind is horrible thing.

    • @thegrumpydeveloper
      @thegrumpydeveloper 7 หลายเดือนก่อน

      Scale that up, add a few hundred devs and try to touch that one css file without breaking things. I’ll be busy shipping tailwind in production while someone sweats that monster file and debates Bem naming standards of a giant oversized css littered with unused classes and all those classes that were supposed to be reusable but end up being nonsensical because of the cascade.

    • @codokit
      @codokit 7 หลายเดือนก่อน +1

      @@thegrumpydeveloper CSS modules was invented in 2015 I guess. Plus do not mix class scouping and CSS design system. You can have own design system that adopted for your needs instead of tons of tiny CSS classes.
      Example: you can have one ".toolbar" that adopted for many usecases instead of each time describe the same via Tailwind. You can define react component of cource, but you need react in that case. Poor design system provocate to use a tons of libs.

  • @mehrabmahmudpur6984
    @mehrabmahmudpur6984 7 หลายเดือนก่อน +1

    Bringing css to js was a big mistake of all the time

  • @doksara420
    @doksara420 6 หลายเดือนก่อน

    StyleX? Really? How much did meta pay you to say that?
    StyleX literally came up couple of weeks ago acting like they invented the term “zero runtime” while all other libraries like PandaCSS / vanilla-extract / KumaUI had it years ago 😂😂

  • @tibitomuta7996
    @tibitomuta7996 7 หลายเดือนก่อน

    Codding is dead.... AI is taking over!
    Is a waste of time...

    • @HumanoAI
      @HumanoAI 7 หลายเดือนก่อน +1

      Not completely dead, but a lot of things will go no code. Knowing how to prompt, that isn’t say knowing your language functionality and the terms to use AI in development will be key. I’m thinking frameworks will be used less by the new generation, since most js needed can be produced by AI and it can do back end. You will need to understand functionality and terms. There will be many no code solutions. I have a custom GPT producing sites with one word, obviously they’re simple sites but. One word such as “mechanic” produces images and the content, SEO, for a website for auto mechanic and the code. CSS happened to be hard for AI, not in explaining but in creating good visuals. We’re six months in and they say the next six months with exponentially increase in intelligence. Not dead but there will be a lot of easy methods to develop some pretty in debt stuff.

  • @fwdflashwebdesign
    @fwdflashwebdesign 6 หลายเดือนก่อน

    Coding is dead, AI si taking over!!!