Why you should look into these React component styling options!

  Рет қаралды 89,298

Academind

Academind

4 жыл бұрын

Styling React components is easy and difficult at the same time. There are so many options! Inline styles, styled components, vanilla CSS, CSS modules and more. Let's take a closer look at the best alternatives!
Join the full "React - The Complete Guide" course: acad.link/reactjs
This course might also be interesting: "React Native - The Practical Guide": acad.link/react-native
This video comes with an article you shouldn't miss! You also find all the source code links there: www.academind.com/learn/react...
Check out all our other courses: academind.com/learn/our-courses
----------
• Go to www.academind.com and subscribe to our newsletter to stay updated and to get exclusive content & discounts
• Follow @maxedapps and @academind_real on Twitter
• Follow @academind_real on Instagram: / academind_real
• Join our Facebook community on / academindchannel
See you in the videos!
----------
Academind is your source for online education in the areas of web development, frontend web development, backend web development, programming, coding and data science! No matter if you are looking for a tutorial, a course, a crash course, an introduction, an online tutorial or any related video, we try our best to offer you the content you are looking for. Our topics include Angular, React, Vue, Html, CSS, JavaScript, TypeScript, Redux, Nuxt.js, RxJs, Bootstrap, Laravel, Node.js, Progressive Web Apps (PWA), Ionic, React Native, Regular Expressions (RegEx), Stencil, Power BI, Amazon Web Services (AWS), Firebase or other topics, make sure to have a look at this channel or at academind.com to find the learning resource of your choice!

Пікірлер: 146
@TheAkiller101
@TheAkiller101 3 жыл бұрын
This guy is personally responsible for like 60% of my coding knowledge
@generalwill10
@generalwill10 2 жыл бұрын
For real. His React course on Udemy *chefs kiss*
@gvsakhil143
@gvsakhil143 4 жыл бұрын
You are my lifesaver Max. I learned Angular from your course before a year and now I am in very good job. I also learned Nodejs and I am now also a FullStack and MeanStack Developer. Thanks a lot again. Keep going on we support u :)
@academind
@academind 4 жыл бұрын
Thanks so much for your awesome feedback and support!
@amalitsky
@amalitsky 3 жыл бұрын
Man, I love you for introducing separate CSS file and BEM naming concept! Thank you so much! Didn't see that coming in react corner of frontend world. IMO simply the best approach of all. CSS modules is like a cherry on top of the cake
@Thewowhahahawow
@Thewowhahahawow 4 жыл бұрын
Great tutorial, I love how you explain how certain code operates behind the scene (example: 8:35 ) . It really gives us deeper understanding into the code you're writing unlike most tutorials on youtube which are often just copy and write. I think this is what differentiates from a average developer to a great developer and I'm very glad you are spreading this deeper knownlowdge across to your students online. This is a KEY difference that stands out in your tutorials. Keep it up! :)
@waldiniman
@waldiniman 3 жыл бұрын
Thank you my dude. You're exceptionally lucid in your descriptive modeling of concepts, and have a real talent for communicating the various aspects concisely, yet thoroughly. Very helpful.
@villerintala7777
@villerintala7777 4 жыл бұрын
No matter what programming tutorial I am looking for, nowadays I come directly to check Max's video if it exists about that topic. Always the most straight-forward and understandable approach. Time well spent. Thanks, keep these coming!
@academind
@academind 4 жыл бұрын
That's so great to read Ville, thank you very much!
@luis_soul1
@luis_soul1 4 жыл бұрын
You’re the best man. I wasn’t sure what are the best practices to css my react project and I was struggling a lot. It’s a small application with 3 pages. Now I can decide which one fits better for my project. Personally, even though it’s a small project, I really believe that CSS Modules are the best method and more comfortable than the other options. Like you said it gives you the best of both worlds. Thank you so much for sharing knowledge, you’re the best.
@orimazrafi9978
@orimazrafi9978 4 жыл бұрын
Amazing how much material you squeeze into one video. that set right many things for me. Thank you!
@matthewwhite3744
@matthewwhite3744 2 жыл бұрын
This is exactly what I was looking for to solve an issue where I had multiple different buttons in an app that I wanted to have their own styles, but not use inline styling. Thanks a million!
@fhelipeturati1483
@fhelipeturati1483 4 жыл бұрын
Max, you are the man! Thank you so much for all your videos!!
@zakarygriffin3280
@zakarygriffin3280 4 жыл бұрын
Your videos are a breath of fresh air in the developer world. It's not often that I find creators that explain things so clearly and elegantly. Thank you, this is just what I needed.
@academind
@academind 4 жыл бұрын
Wow, thank you very very much for these wonderful words Zakary!
@anilmohan9961
@anilmohan9961 3 жыл бұрын
Very well explained. Liked the way Maximilian presented the concepts here, as he always does!
@prasangsharma7
@prasangsharma7 4 жыл бұрын
Very well explained. Highly recommended for anyone who has recently started learning React.
@crystalclear178
@crystalclear178 2 жыл бұрын
Now I'm more confused... please tell me how we should use css in proper way...there are too many ways which should we use??
@arishshah1142
@arishshah1142 4 жыл бұрын
Thanks! I really wanted to learn Styled Components and using CSS modules without running `npm run eject`.
@badytouray294
@badytouray294 3 жыл бұрын
Love this video :-) Easy to understand and no effort at all 😎 Keep the content coming guys.
@HIghtowerSever
@HIghtowerSever 4 жыл бұрын
Useful material. Thanks a lot Max!
@StrangeIndeed
@StrangeIndeed 3 жыл бұрын
I was confused by all the options and this video made it all clear to me. Thanks c:
@theycallmewolf
@theycallmewolf 4 жыл бұрын
Dude!! Big like from a Portuguese junior coder!
@Apparentt
@Apparentt 4 жыл бұрын
I would personally highly recommend react-jss for styling components, I think what’s missed which is the real strength of the mentioned package (as well as styled-components, amongst others) is being able to pass a theme around to components and also being able to access component props within the styling; the latter can become very cumbersome using vanilla css or css modules (having to toggle class names based on props or state)
@NeerajLagwankar
@NeerajLagwankar 2 жыл бұрын
This. I was introduced to JSS via Material UI and I honestly cannot go back to only CSS or other CSS in JS solutions. The amount of flexibility you get is mind boggling.
@reactstuffreact4500
@reactstuffreact4500 4 жыл бұрын
great videos, good paced. thank you
@omriterem6448
@omriterem6448 4 жыл бұрын
Amazing video. Thanks Max
@bayasahamed1815
@bayasahamed1815 Жыл бұрын
Thanks for the clear explanation max.
@rk_nyra
@rk_nyra 2 жыл бұрын
Very helpful! Thanks for sharing this!!
@Pareshbpatel
@Pareshbpatel 2 жыл бұрын
Excellent Overview on React Component Styling {2021-09-27} , {2022-02-28}
@ernestomotta5178
@ernestomotta5178 2 жыл бұрын
This is pure gold, Thank you!
@saramshshrestha7641
@saramshshrestha7641 3 жыл бұрын
Thank You So Much Max.
@TitiloTeam
@TitiloTeam 4 жыл бұрын
Excellent Video! Thanks a lot!
@helinli7093
@helinli7093 4 жыл бұрын
thank you! really helpful!
@bohodirrahmonov8021
@bohodirrahmonov8021 3 жыл бұрын
Thanks bro vey much. Untilk this day i dont have been found this kind of information
@diondreedwards30
@diondreedwards30 4 жыл бұрын
Hey, great video. What do you think about styled-jsx?
@ek4m81
@ek4m81 4 жыл бұрын
is the last one same with using "use npm eject and configure webpack"?
@itzsrikanth
@itzsrikanth 3 жыл бұрын
Awesome video, Max. Can you please tell us your personal take on FCP for CSS-in-JS solutions?
@kazenohito7641
@kazenohito7641 4 жыл бұрын
Amazingly well thought out. I'm an Angular guy so jsx is still REALLY weird to me but this makes alot of sense. css in js and js to write html embedded with css is a whole topic, seemingly almost native to react.
@academind
@academind 4 жыл бұрын
Thank you very much for your fantastic feedback Kaze!
@stannone7272
@stannone7272 4 жыл бұрын
Since you can explain so well. I would appreciate some advanced topics explained.
@kwasnakawa
@kwasnakawa 3 жыл бұрын
Great video. Thanks!
@fluntimes
@fluntimes 4 жыл бұрын
I learned CSS Modules in Gatsby and thought, "wow, these are cool". Not long after that I learned about Styled Components and thought, "this is possibly the greatest package ever added to React. Seriously, if I have to use a global CSS file in React now I feel a bit weird!?
@hettalamazigh6251
@hettalamazigh6251 4 жыл бұрын
Thank you so much
@nwobodogeorge5370
@nwobodogeorge5370 4 жыл бұрын
Thank man. I love it.
@neosarchizo
@neosarchizo 4 жыл бұрын
Thanks for good video!!
@BrownieloveMike
@BrownieloveMike 4 жыл бұрын
Hi Max How do i get hold of you with regards to crating an app? I could not find clear company contacts on your website.
@TheEtsgp1
@TheEtsgp1 4 жыл бұрын
Hey what camera and video setup do you use in you studio to get such clean high def videos. Camera? Mics? lights? Ect?? Thanks
@webentwinkler
@webentwinkler 4 жыл бұрын
Great comparison, Max. I'm also completely on board when it comes to preferences: Using inline-styles outside of the occasional hard override is a cardinal sin in any web project, no matter the framework/library. I found that styled components, while being a bit better, are still not preferable, because it still sacrifices useful CSS features as the cascade and inheritance. The only good use I found for it is when working with React transition groups with custom animations, for that purpose it is actually very well suited. It actually never made sense to me why anyone would want to force CSS into JS completely. HTML, CSS and JS are three separate technologies that, while of course being designed to work together in unison, are separate for a reason and trying to force one or two of them into the other always comes with huge drawbacks while bringing little to no gain. And while IDEs are smart enough now that they no longer stumble across JSX, styling is still an entirely different beast. And, as you said, if a project has dedicated UI and Business Logic developers, forcing the UI guys to deal with JS files is just bad for everybody. The UI dev gets thrown out of their comfort zone, no longer can have proper IDE support and useful helpers like stylelint and just has a harder time overall. And on top of that, at least when using inline styles or styled components that are defined inside the component they belong to, they constantly produce merge conflicts for the JS devs, who also have to deal with larger files which makes then less readable. What I never understood regarding CSS Modules in React is why they thought they'd have to completely obfuscate the class names. That makes it unnecessarily difficult to debug CSS issues, because one cannot simply copy the class name and search for its style definition in the code base. In my opinion, the best approach to this has been achieved by Svelte, where they keep the original class name from the CSS definition, but for scoped styles they simply add the unique class name to the same element and then the style definition output changes from the source ".my-class-name{ ... }" to ".my-class-name.uniqueClass{ ... }". Why did no one think of that before? But then again, that is a question I asked myself all the time while learning about Svelte... ;-) Congratulations on your great Udemy Svelte course by the way, Max, I cannot recommend that enough! Anyway, back to topic: All those reasons listed above are why, for the react project I'm currently working on (which is based on react-boilerplate which normally uses styled components per default but we only kept them in for transitions) we are using separate SCSS files (one in each component/container folder), which are automatically found and grouped together by webpack, together with a bunch of global definitions for inheritance (like base styling, CSS reset rules, etc.) and simply adhere to BEM conventions. Tried and true and still works best, especially for separation of concerns.
@crystalclear178
@crystalclear178 2 жыл бұрын
Exactly.. . totally agree...I thought I'm new in react and that's why it feeling weired with these css and react thing...i thought ill get better understanding and will figure out the actual way of including CSS in react....but I think thr is no way...
@ramasamynp8175
@ramasamynp8175 4 жыл бұрын
Could you please upload videos for storybook react ui components ?
@jshtmlcss
@jshtmlcss 4 жыл бұрын
Grate vid, from my 20 years experience: CSS Module was looking like the best option however what if i want to refer to the defined className i defined in a global css file ( with a sector like .xyz {color:green }, I would not be able to as the className name will be renamed by the webpack loader. StyleCompoents slows down the coding , why should I have to build a wrapper for every object , even a simple DIV , and clutter up my project with all this code, that also using uncommon JS Tag Template Syntax , however i found it good to inject values from jsx into it to create dynamic styles. I found using one global css file for shared css is a better way , having all css in one file ( editors these days will tell you if something is broken, no need to make one new css file per component , cluttering up my code base with simple styles ) and then if i need to change a style based on some user preference or some other state, i can override it with inline styles. I like to keep things simple, easy to read , easy to learn , less code , less files means less code that to brake , less code to test,. This allows me to have more time to build the real stuff .
@anvarichn
@anvarichn Жыл бұрын
Great video! I think, Typescript version of that would be event more valuable!
@kenwanjohi5128
@kenwanjohi5128 4 жыл бұрын
can't thank you enough..very helpful
@academind
@academind 4 жыл бұрын
Glad it helped
@Montclairsoccer1
@Montclairsoccer1 4 жыл бұрын
Really great video!
@academind
@academind 4 жыл бұрын
Glad you liked it!
@KidJV
@KidJV 3 жыл бұрын
thanks! subscribed
@aburaihan-py4vi
@aburaihan-py4vi 2 жыл бұрын
Excellent!
@AmanNidhi
@AmanNidhi 4 жыл бұрын
which one do you prefer? There are so many ways to style a react app, which one is better and which one has the future?
@juancamiloq1
@juancamiloq1 4 жыл бұрын
Awesome videos
@mahmoudnoby6204
@mahmoudnoby6204 4 жыл бұрын
can you help me .. I am confused which is more better when building angular app bootstrap or angular material ..I hope to help me
@ElderESG
@ElderESG Жыл бұрын
This is gold❤
@Kanexxable
@Kanexxable 4 жыл бұрын
Can you please do a video about model view controller vs model view view model. And how they apply in Vue angular and react. I have no idea what a view model is and what it looks like at all. In Vue is the root Vue instance the view model. I don’t get it. Yes I’m now starting to learn typescript and don’t know how well I should use it before going to angular.
@TechnoDB
@TechnoDB 4 жыл бұрын
Helpful video.. :)
@oleksiisytar9872
@oleksiisytar9872 4 жыл бұрын
Great things, but what about SCSS, or LESS files, is it working the same?
@HoangHuy-nq1if
@HoangHuy-nq1if 4 жыл бұрын
good job
@ronmilich123
@ronmilich123 3 жыл бұрын
Are you single Max? Best tutor ever!!!!
@mjmagic12
@mjmagic12 3 жыл бұрын
How do you use google fonts with styled components?
@MERNStack
@MERNStack 4 жыл бұрын
hope syntax highlights for styled components will be supported in vs code
@vaibhavm1986
@vaibhavm1986 4 жыл бұрын
Hey Max I have to do set up for new project kind of confused between webpack and create react app... Could you please guide...so that it becomes easier to decide
@mbround18
@mbround18 4 жыл бұрын
Create react app uses webpack. My suggestion is use create React app of your unsure what you are doing and or try suing alternatives like parcel or fuse-box.
@lullalullafy
@lullalullafy 3 жыл бұрын
Excellent
@drdDavi
@drdDavi 4 жыл бұрын
40% of my react knowledge comes from this channel!
@muchvibrant
@muchvibrant 4 жыл бұрын
what about the other 60%?
@MistaT44
@MistaT44 4 жыл бұрын
@@muchvibrant Practice
@lukaszwalczak3814
@lukaszwalczak3814 4 жыл бұрын
@@MistaT44 Golden answer :)
@RonaldJayBuayan
@RonaldJayBuayan 3 жыл бұрын
import css is only dynamically inject on dev however on distribution build its compiled in one css.. i was hoping it was going to be injected in build too so it be separated from the main and would be beneficial to the initial load time.. is there a way to achieve this?
@matheustavares4442
@matheustavares4442 3 жыл бұрын
omg, i bought you react couser and youtube recommend you
@almakay01
@almakay01 2 жыл бұрын
I feel like styled components are so cool!
@vikramingleshwar5732
@vikramingleshwar5732 3 жыл бұрын
vielen danke, god bless you.
@turbulantarchitect5286
@turbulantarchitect5286 2 жыл бұрын
what are the cons to use both - css file and styled components?
@MichaelSalo
@MichaelSalo 2 жыл бұрын
14:50 I'm surprised the pseudo class selector is written without an ampersand here. Is this correct?
@Robin-il8nc
@Robin-il8nc 4 жыл бұрын
I'm currently starting a new React Project and im pretty new to it. My preferred way of writing CSS would be modules with scss. But how do you handle and structure global or Responsive Styling?
@pulga961
@pulga961 4 жыл бұрын
bootstrap for responsive. you can create global styles.
@abdelaesus6678
@abdelaesus6678 3 жыл бұрын
so perfect
@pratibhalovesu
@pratibhalovesu 4 жыл бұрын
Max can u make a styled component videos or tutorial
@micoberss5579
@micoberss5579 4 жыл бұрын
For using CSS modules in CRA, dont you need to eject the project and tweak lines in webpack settings?
@academind
@academind 4 жыл бұрын
You can do that, too - in newer versions of CRA, you can use the built-in functionality as well though.
@ebrahimjamal449
@ebrahimjamal449 3 жыл бұрын
sir plz react short key for example racc press which keyboard key
@Trazynn
@Trazynn Жыл бұрын
Why is this 3 year old video the only video on KZbin that explains styled components properly?
@AnthonyPaulT
@AnthonyPaulT 3 жыл бұрын
Max so what method is your preferred method?
@suki5593
@suki5593 4 жыл бұрын
More angular and Ionic please
@fxnoob
@fxnoob 3 жыл бұрын
good stuff.
@mubarkmurtda4735
@mubarkmurtda4735 4 жыл бұрын
Best way is to use sass module's unless you are using material ui so you can use jss.... although styled components is good there bundle size is huge
@unmeymahaddalkar4842
@unmeymahaddalkar4842 4 жыл бұрын
I was just looking at which framework to use to style react components!
@divyanshubhatnagar4601
@divyanshubhatnagar4601 4 жыл бұрын
How to remove unused css using the css modules and webpack or maybe some other way?
@kostiantyn187
@kostiantyn187 4 жыл бұрын
The best way to understand that something is not used is by using the styled-components, your IDE automatically shows to you what you've not used. For CSS modules you've to use the POST CSS & webpack config to rid of some unused css, but you'll have such shitty unused code in the codebase, that is why I do not prefer the pure css solutions any more
@dallindavis2131
@dallindavis2131 2 жыл бұрын
Who needs a university education when you have Max?
@hiteshsuthar1097
@hiteshsuthar1097 2 жыл бұрын
Now i knew why search engines recommends me Styled Components Vs CSS Modules when i search for css modules🤣
@javadmohammadi3943
@javadmohammadi3943 2 жыл бұрын
very powerfull
@aleksd286
@aleksd286 4 жыл бұрын
Been using styled components for almost a year now. It's purely amazing. Please don't forget to mention theme providers..
@vaibhavm1986
@vaibhavm1986 4 жыл бұрын
Hi Alesk, did u get chance to notice whether final css is injected like link rel or it gets injected directly in DOM because if it gets directly gets injected in dom then bundle size would increase?
@aleksd286
@aleksd286 4 жыл бұрын
@@vaibhavm1986 it gets injected into the dom, each styled component receives a randomly generated class name, that refers to some css styles
@vaibhavm1986
@vaibhavm1986 4 жыл бұрын
@@aleksd286 u are using webpack or cra... To reduce bundle size are you using lazy imports? Else all styles injection into Dom would make bundle size bigger?
@aleksd286
@aleksd286 4 жыл бұрын
@@vaibhavm1986 I am using nextjs, it comes with webpack by default
@vaibhavm1986
@vaibhavm1986 4 жыл бұрын
@@aleksd286 oh ok cool 🙂
@meghalbisht6768
@meghalbisht6768 4 жыл бұрын
23:45 is when you get module css!
@zetiraid9857
@zetiraid9857 4 жыл бұрын
this is what I waiting for .. thanks
@Ziberac
@Ziberac 4 жыл бұрын
What IDE/Editor is this?
@academind
@academind 4 жыл бұрын
It's Visual Studio Code.
@911madza
@911madza 4 жыл бұрын
Your thoughts on reactstrap?
@chispablo
@chispablo 4 жыл бұрын
bootstrap as itself is losing a lot of popularity, a lot of people are going back to pure CSS, just as it happened with jQuery and people went back to vanilla JS. So reactstrap IMO is not that good if you want your site to have a distinguished style, but it's pretty good if CSS is not your forte
@aleksd286
@aleksd286 4 жыл бұрын
pointless. does not achieve much nowadays. for a grid you have CSS grid, for all other things you do them separately or use things that are react based already, like MaterialUI for React, for Vuetify or VueJs, these have much more options. Bootstrap is out-dated.
@user-yk3if2ku4e
@user-yk3if2ku4e 4 жыл бұрын
Maybe you will create a course about optimization in React?
@sumanth3036
@sumanth3036 4 жыл бұрын
I like of conventional css files
@Cdswjp
@Cdswjp 3 жыл бұрын
what's the best way to write css these days?
@jyotipandey9218
@jyotipandey9218 3 жыл бұрын
Styled components do not seem to work on internet explorer though.
@RoyerAdames
@RoyerAdames 3 жыл бұрын
Crear content thank you
@Timur21
@Timur21 3 жыл бұрын
I like css modules the best I think. Radium is also not too bad, but sometimes when inspecting the tree of react components, it's annoying to just see Radium Components everywhere...
@greenshaheen6716
@greenshaheen6716 4 жыл бұрын
Awesome! Please make a video on how to learn from courses like ur udemy courses . And what is best way to learn from courses
@kiana5066
@kiana5066 3 жыл бұрын
Ever notice how round-about all these "solutions" are? Why not have something like Vue.js single-file components?
@jeffersonribeiro1669
@jeffersonribeiro1669 4 жыл бұрын
Hi Max, looking handsome! I have question, where can I submit a video idea?
@tranhuuthu991990
@tranhuuthu991990 2 жыл бұрын
writing css in style component has no hint as in normal css file. I was wondering why reactjs has so many third library and definition. also the style component look stupid and weird syntax The extending style works as oop design pattern, but react now is more functional pattern.
@ibrahimkhurshid4339
@ibrahimkhurshid4339 Жыл бұрын
Thanks, pal !!! I was lost in what kind of CSS to use. Seems like component.module.css is the one I would go with...
@moofymoo
@moofymoo 3 жыл бұрын
now styled-components allow to write: styled.div({color:'red'}); styled.div(props=>({color:props.color});
You might not need useEffect() ...
21:45
Academind
Рет қаралды 155 М.
React.js Hooks Crash Course
1:02:54
Academind
Рет қаралды 316 М.
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 12 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 7 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 64 МЛН
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 106 МЛН
CSS-модули, SASS/SCSS и сброс стилей в React-приложении
18:28
Михаил Непомнящий
Рет қаралды 36 М.
Styled Components Full Tutorial - Style Your Components in React
23:54
React Context vs Redux - Who wins?
31:32
Academind
Рет қаралды 233 М.
7 ways to deal with CSS
6:23
Fireship
Рет қаралды 1,1 МЛН
TypeScript Course for Beginners - Learn TypeScript from Scratch!
3:16:40
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 930 М.
useContext() + useReducer() = Magic?
22:49
Academind
Рет қаралды 183 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Stop Doing this as a React Developer
12:27
CoderOne
Рет қаралды 161 М.
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 73 МЛН
$1 vs $100,000 Slow Motion Camera!
0:44
Hafu Go
Рет қаралды 28 МЛН
Самые крутые школьные гаджеты
0:49
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 2 МЛН
АЙФОН 20 С ФУНКЦИЕЙ ВИДЕНИЯ ОГНЯ
0:59
КиноХост
Рет қаралды 1,2 МЛН