What Is CSS In JS? / What Is Styled Components?

  Рет қаралды 36,939

Syntax

Syntax

6 жыл бұрын

In this What Is Wednesday, I answer the question. What Is CSS In JS as well as What is Styled Components?
Video Links
Buy VueJS For Everyone: goo.gl/7uft3X
Become a Pro: www.leveluptutorials.com/pro
Affiliate Links
Please use these links when signing up for services to help support Level Up.
Easy Hosting with Netlify: goo.gl/pychVP
Shared Web Hosting: goo.gl/pfC6uc
Level Up Links
Syntax Podcast ft Scott Tolinski & Wes Bos: goo.gl/7jDDxX
Subscribe to the Level Up Newsletter
eepurl.com/AWjGz

Пікірлер: 73
@abrieljohngabriel8686
@abrieljohngabriel8686 6 жыл бұрын
I was trying to convert plain pages to React and having a difficult time with adding classes to specifc buttons. Styled components really helped me a lot to simplify my code and not to create a bunch of classes. :) I believe this is very useful for backend developers trying to go on designing on the front end as well. :)
@antisony2008
@antisony2008 4 жыл бұрын
I don't use them because I've been living under a rock for the last year. Dang this looks awesome
@loka2153
@loka2153 6 жыл бұрын
Great video, Scott I'd love to see a series on Styled Components!
@patrasculucian2403
@patrasculucian2403 6 жыл бұрын
Very informative video. The fact that you are trying to be non-biased, leaving out personal preferences can make your ego angry. But you didn't care about it and I admire you, because it is very damn hard to be like this.
@dpointeck
@dpointeck 6 жыл бұрын
👏 I would appreciate a Miniseries about styled-components. At the moment I'm learning React and I love the component based approach. I find it very convinient to edit the styling in the same file as where my component sits. Thanks Scott for sharing your thoughts on this!
@ahmedmusawir
@ahmedmusawir 5 жыл бұрын
More ... more ... more ... mini-series .... plz plz plz!! There is nothing like this on youtube ...Thanx in advance!!!
@davidluhr
@davidluhr 6 жыл бұрын
A series focus on styled-components would be fantastic. I've been enjoying using it for some time now but love to see other people's approaches.
@syntaxfm
@syntaxfm 6 жыл бұрын
Yeah! I've been doing a lot of chatting with some devs around me about SC and design systems. It's been fascinating to see all the different approaches.
@hanmingzheng5592
@hanmingzheng5592 6 жыл бұрын
A deep dive into SC would be great. There a very few tutorials on SC. Mostly just scratch the surface. Also, it will be fantastic if you can put up a series that uses SC with existing 3rd party css framework. Preferably a framework that also use css in js.
@dallanclawson
@dallanclawson 6 жыл бұрын
I would really like to see a mini series that goes in depth with your specific workflow and usage. I’d like to know how that workflow and usage has changed as well. There are a lot of us CSS guys that get the argument for CSS in JS and now want to see how to make the transition over. This video was a good introduction (teaser 😉) and I’d like to see more!
@alexdeo8869
@alexdeo8869 5 жыл бұрын
Level Up tuts, A mini series on styled components would be awesome!!.cheers !!.. :)
@tylerbenton4495
@tylerbenton4495 6 жыл бұрын
Do you have a repo utilizing Styled components? I love React and Styled components but the problem is face is having a good project structure. I'm currently putting all my Styed components in the same React component file they correspond with but I don't think that's the best way as my components file gets very cluttered with the Styled components. Any repo I can check out to see how you do yours?
@tylerbenton4495
@tylerbenton4495 6 жыл бұрын
I agree with you where you said the only bad thing about using Styled components would be that you'll be locked in to using React, JSX and Styled components. I watched like 5 talks going over it before I knew what is was as I'm someone who only like to use libs if I know they'll be around for a while. I gave it a try and fell in love with it. It honesty makes the code look cleaner and feel more natural. I don't have to worry about using the same class name in one file and having to change it to another. I think Styled components will be here for a while and I feel like even if it unexpectedly was stopped being worked on. Someone would get to work on a new lib very similar to Styled components.
@andrewpoe6344
@andrewpoe6344 6 жыл бұрын
We've built an element query based grid library and use it in prod at work. Hoping to open source it soon!
@pordemoni1743
@pordemoni1743 5 жыл бұрын
Unrelated question, but does anyone know how to change VSCode's folder indentation in the explorer like his?
@lumenwrites
@lumenwrites 6 жыл бұрын
Thank you for an amazing video! Very helpful. One question - does it make sense to use both sass for general styles, and styled-components for some specific elements? Seems like it would ease the transition(if I alfeady have a ton of sass written), and also I might want to have some general styles that apply to everything. Or does it defeat the purpose of styled components being scoped?
@syntaxfm
@syntaxfm 6 жыл бұрын
You can do global styles with SC but I mostly do cascading through based components and extending them. That said, it LUT right now I'm using both Stylus and SC but only because the transition of moving all my CSS to SC is a lot of work.
@ahmaddekmak2645
@ahmaddekmak2645 2 жыл бұрын
Stoppp!! stop letting me think outside of the box. i feel good in my comfort zone of pure CSS magnificent.
@Cubannerd
@Cubannerd 5 жыл бұрын
So, let's see if I get this right. You add a style to every component separately? Every new component you make you add a style to it right?
@kohahn21
@kohahn21 6 жыл бұрын
how to use appenChild with Styled-components ??
@mframon
@mframon 4 жыл бұрын
What VS Code Theme do you use?
@rja421
@rja421 6 жыл бұрын
I have a library of styled components much like your own. I don't have an index though, that is a nice tip which I shall implement myself.
@syntaxfm
@syntaxfm 6 жыл бұрын
Yeah! I have two folders. One for elements.. which is all of my components with an index and one that's for style utilities like breakpoints, color functions, variables also with an index.
@lewis6590
@lewis6590 5 жыл бұрын
At first I thought it would be gross to put CSS in my components but it's basically what I was doing with class names anyway. .header-link .social-link .caption-link etc etc. This way it is at least easier to structure my project as a group of interlinking 'things' rather than components on one side that pull styles from different files over on this other side. I can still reuse stuff by exporting the styled component, too. Now I'm just trying to figure out how to use theming in an elegant and maintainable way.
@JacobDFrank
@JacobDFrank 6 жыл бұрын
Yes to the miniseries or perhaps just one more explainer and tutorial
@kniarzyn
@kniarzyn 6 жыл бұрын
Waiting for mini series on styled components.
@wilsonlopez697
@wilsonlopez697 5 жыл бұрын
How can I traslate this CSS to Styled Component ? .form-signin .form-signin-heading, .form-signin .checkbox { margin-bottom: 30px; } or this one... .form-signin input[type="password"] { margin-bottom: 20px; border-top-left-radius: 0; border-top-right-radius: 0; }
@BrianBest
@BrianBest 5 жыл бұрын
STRONG OPINIONS!!!!!! :P No i mean the reason I can't use this is because it doesn't fit in my stack right now. but more then that I just see some issues coming up with css-in-js with just server side rendering. Scoping is great but i'm not sure if its worth the extra server configuration / potential performance hit for time to first load stuff. idk still early days for me on this front, maybe I'll change my mind
@RobertR1611
@RobertR1611 6 жыл бұрын
My strong opinon: Thank you for posting.
@syntaxfm
@syntaxfm 6 жыл бұрын
My kind of strong opinion.
@programadorhispano5203
@programadorhispano5203 6 жыл бұрын
Hello I do a betting code, I capture the results of the game with Sun but I do not know how to make the script know if the user won or lost when the user presses the button My friend I am your follower on the web, please help me thanks
@FishTalkFish
@FishTalkFish 5 жыл бұрын
I love seeing his next browser tab with the search "Why use css in JS?"
@ChrisFotosMusic
@ChrisFotosMusic 4 жыл бұрын
damn lmao
@kylerjohnson3317
@kylerjohnson3317 4 жыл бұрын
In the video, he shows the viewer that tab when he's talking about how controversial CSS in JS is. He didn't just google it and make a video about it or anything. He shows that when you google that, the top 3 results include an article arguing in favor of CSS in JS, an article that is kind of "on the fence" about it, and another one that argues against it.
@acqzuel
@acqzuel 6 жыл бұрын
If everything is scoped, does that mean that theming your app would just be overwriting component css globally? I feel like that is messy. It seems that nobody is addressing this.
@muscaiu
@muscaiu 6 жыл бұрын
Suggestion for a "What is episode": What are mixins?
@theoligarchist1503
@theoligarchist1503 4 жыл бұрын
will be very interesting if this can be used from Rust, then we rust programmers wont have to worry about ever touching CSS.
@loki6841
@loki6841 6 жыл бұрын
and its so easy
@thealpha_9
@thealpha_9 6 жыл бұрын
One argument you didn't mention is performance, is takes much more for the browser to parse this JS code.
@syntaxfm
@syntaxfm 6 жыл бұрын
Depends on use case. I wouldn't say is "much more" and if you are using SSR it's going to be much less for initial load.
@chanlito4896
@chanlito4896 6 жыл бұрын
Can you do a tutorial on material UI next? Explain their CSS in js usage would be nice.
@dusanjovanov
@dusanjovanov 6 жыл бұрын
Styled components are great, but it's very hard to use them with typescript
@greendragon4151
@greendragon4151 2 жыл бұрын
i would like a miniseries on styled-components.
@trappedcat3615
@trappedcat3615 6 жыл бұрын
Im liking just CSS variables in JS
@syntaxfm
@syntaxfm 6 жыл бұрын
Def loving CSS variables myself too!
@bigfoot131
@bigfoot131 6 жыл бұрын
Give us a tut on styled components
@pelumiman2799
@pelumiman2799 6 жыл бұрын
pls do the miniseries
@ExplicitPanic
@ExplicitPanic 6 жыл бұрын
Little offtopic but... What's your terminal color scheme?
@syntaxfm
@syntaxfm 6 жыл бұрын
Level Up Official.
@younmecreate
@younmecreate 4 жыл бұрын
I am not too good in this but here are my points: 1.) As a computer Science Student/developer I feel CSS in JS breaks the Single responsibility principal, and the components functionality is getting tied with its look and feel. 2.) Also I feel it get messier when you start using media queries and pseudo classes 3.) To some extent it feels like it may not go well with CSS frameworks such as bootstrap. 4.) CSS was created for look and feel and JS for functionality, I don't know how mixing these things together will help especially in case when multiple people are working like CSS guy and another one very proficient in JS, so there may be some issues. 5.) Separation of concern is lost here, so if someday if you want to change just the styling or just the functionality, we may end up (to err. is human) affecting the other one. EDIT: 6.) If we are interested in directly modifying things, then it reminds me the era of JQuery, where its enabled us to easily manipulate styling and even the DOM. Obviously it feels great to be able to modify things by our hands, but wasn't this the very reason the Component based approach was started in the first place!. 7.)(Its a Question) I am not sure how good it will be with event handaling in case of nested styled components?
@Ericsicons
@Ericsicons 6 жыл бұрын
one of the greatest benefits of styled components that you can control css values at run time
@hanmingzheng5592
@hanmingzheng5592 6 жыл бұрын
Might be a weak point. But I really like to put everything(html, css, js) in js and see them all in 1 file. Makes me feel a lot better.
@sr_aman
@sr_aman 6 жыл бұрын
hanming zheng this is my opinion also. All the things that makes up component are in one file. It feels waaaayyyyy better.
@FrontendZilla
@FrontendZilla 6 жыл бұрын
Really informative Video, but hanming zheng Its easy use script tag to insert script and style tag to insert css on the same page know more #wantedtalks
@lucasvilela18
@lucasvilela18 6 жыл бұрын
I use styled components everyday now ! And its great but there is donwsides too ! A lot of repetition ! You have to have a better understand of pure css ! Its ok when you doing components and small pieces that is fine.. But when you get into big layouts you have to do a lot for yourself and sometimes a bootstrap is better for that ! You need more planing for the future when using them !
@akhilk5121
@akhilk5121 4 жыл бұрын
For me lock-in to the library is a huge no-no! One thing we were always taught not to do.
@syntaxfm
@syntaxfm 4 жыл бұрын
If you use just about any library there is some degree of lock in. At least with styled components you are basically just writing sass code anyways.
@r-i-ch
@r-i-ch 6 жыл бұрын
Two reasons I don't care for CSS-in-JS. 1. Putting CSS in JS violates the separation of concerns which is the whole reason we stopped inline-ing to begin with. 2. (Depending on your build sys) Simple changes will likely need to be rewritten in multiple locations.
@syntaxfm
@syntaxfm 6 жыл бұрын
I'm not sure I follow the 2nd problem. With most css in JS systems you are writing reusable components that would only need to be updated in 1 place
@wilcas5349
@wilcas5349 4 жыл бұрын
I use styled components because they are not dumb.
@darwinmanalo5436
@darwinmanalo5436 6 жыл бұрын
yes google "why use css in js" haha
@syntaxfm
@syntaxfm 6 жыл бұрын
The results are hilariously all over the place.
@FrontendZilla
@FrontendZilla 6 жыл бұрын
css and js are front end technologies, google also have it so they also use it, every website uses it
@prashantindurkar
@prashantindurkar 6 жыл бұрын
First
@honkskillet
@honkskillet 6 жыл бұрын
You should redo this one and actually show us code and not try to sell us on the it for 10+ minutes.
@syntaxfm
@syntaxfm 6 жыл бұрын
honkskillet All CSS in js libs are different, so showing code of a few of them would only do so much. Also, I'm not trying to sell anyone on anything. Usage of something like this is a choice your team needs to make. I have nothing to gain or lose either way. I'm not invested in your workflow, just trying to discuss the options available. Potentially a better idea for that kind of video would be to make a comparison of differenet css in js libs but even then you would have to separate by platform.
@majorhumbert676
@majorhumbert676 5 ай бұрын
Nobody ever reinvented CSS, why is that? It's because it sucks, and because it's designed to style a markup language called HTML, not unlike other markup languages such as Markdowk, LaTeX, and AsciiDoc.
@syntaxfm
@syntaxfm 5 ай бұрын
I’m not sure I follow. CSS is a great language
@jahongirbozarov3135
@jahongirbozarov3135 4 жыл бұрын
90% of this video is just talking making you wait long to see the actual syntax
@b.6603
@b.6603 4 жыл бұрын
Yeah? This is a 'what is' video, not a tutorial. It's supposed to be talking, not teaching syntax.
@manuelsuarezabascal75
@manuelsuarezabascal75 5 жыл бұрын
CSS In JS is an abomination
@syntaxfm
@syntaxfm 4 жыл бұрын
Why?
What Is Webpack?
13:59
Syntax
Рет қаралды 46 М.
CSS in JS: My favorite
17:37
Harry Wolff
Рет қаралды 15 М.
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 13 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 70 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 7 МЛН
What Is GraphQL?
14:27
Syntax
Рет қаралды 450 М.
What Is Unit Testing?
10:19
Syntax
Рет қаралды 8 М.
7 ways to deal with CSS
6:23
Fireship
Рет қаралды 1,1 МЛН
Enums considered harmful
9:23
Matt Pocock
Рет қаралды 199 М.
Why you should look into these React component styling options!
27:17
Laravel Dusk: painless browser automation
20:49
Aaron Francis
Рет қаралды 11 М.
What Is Jest?
5:24
Syntax
Рет қаралды 17 М.
Self Hosting Reverse Proxy Servers
17:08
Syntax
Рет қаралды 2,9 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 926 М.
Introduction to React #7 | CSS in JS
6:08
Jack Herrington
Рет қаралды 10 М.
Не ешь конфеты лежа
0:26
Даша Боровик
Рет қаралды 1,6 МЛН
У Гриффинов суперсила | ГРИФФИНЫ
1:00
Вот это комплимент😏 #сериал #рек #кино
0:26
POV Joy and Anger's house - Inside Out 2
0:40
AmogusMan
Рет қаралды 10 МЛН