Create a color theme mixin with Sass

  Рет қаралды 39,945

Kevin Powell

Kevin Powell

Күн бұрын

I'm working on a course that deep dives Sass (and more!): beyondcss.dev
🔗 Links
✅ The code: codepen.io/kevinpowell/pen/bG...
⌚ Timestamps
00:00 - Introduction
00:35 - Starting variables
01:43 - The basics of the mixin
02:33 - Adding arguments to the mixin
04:00 - The problem with passing a theme variable as an argument
05:00 - Fixing the problem
05:45 - What if we want it to also accept gradients?
06:37 - Adding an if/else statement
09:30 - Allowing it to accept custom colors as well
10:28 - Go Beyond CSS
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZbin channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 52
@eyeofthetiger7
@eyeofthetiger7 2 жыл бұрын
I'm pumped about your "Go Beyond CSS" I've been looking for a course lately that would teach truly advanced scss with great project structure and implementation to take full use of Sass capabilities
@zachjensz
@zachjensz 2 жыл бұрын
I actually prefer seeing the SCSS side by side with the CSS rather than the webpage. As a sass beginner I like to see what CSS is being transpiled!
@KevinPowell
@KevinPowell 2 жыл бұрын
Good point, I probably should have done this in VS Code to make it easier to see both at the same time
@proteus1
@proteus1 2 жыл бұрын
@@KevinPowell next project
@MuhammadAhmedAshraf
@MuhammadAhmedAshraf 2 жыл бұрын
@@KevinPowell can you make a video on paper ripple animation like youtube has when the internet is not avaiable the RETRY Button You should also do another live coding video
@guillermomf
@guillermomf 2 жыл бұрын
I've just begun a deep learn about Sass and your video gimme a lot of ideas to work. Thanks!!
@NZMPlays
@NZMPlays 2 жыл бұрын
You're the best man. You're one of the reasons I am going to be able to make more money at my job in the coming years, your videos are helping me make purchase funnels and Im getting to finally stretch my design legs using your tricks! Thanks Kev!
@joebanfi8531
@joebanfi8531 2 жыл бұрын
Great video, can't wait for the course.
@jennifermagpantay7933
@jennifermagpantay7933 2 жыл бұрын
Another great video, Kevin!!! You're a star!!!
@Mego4884
@Mego4884 2 жыл бұрын
man thank you, I love how the universe(or youtube algo) works, but this is truly needed right now in my life and thank you for this idea
@AlThePal78
@AlThePal78 2 жыл бұрын
never knew about the if statment or list that is awesome wow amazing I am truly mind blown how css came a long way with the scss etc..
@donmorris4506
@donmorris4506 2 жыл бұрын
You the man Kevin. You have helped me up my game with my web development. An idea: I had a customer who asked me to give users the option to choose the theme they wanted to use. I did this with bootstrap themes from boot swatch by providing a drop down in the navbar to allow selection of a theme and the enabling and disabling the stylesheets in the html head via js. It works fine by changing things on the fly, but I would love to see an alternative way to provide user selectable color themes.
@xervoo6419
@xervoo6419 2 жыл бұрын
One (the only?) alternative is using css custom properties (variables) throughout your css and changing a single role on the body to change what colour the variables have.
@KevinPowell
@KevinPowell 2 жыл бұрын
Yeah, like Xervoo said, using custom properties would be the way to go there. The only alternative is having a lot of unused CSS sitting around. You could even have a class, like .theme-a {} and all the variables are defined in there with one theme, an then a .theme-b {} that has the same variables, but with different values. It would result in unused CSS, but it probably wouldn't be *that* much. Alternatively, you could avoid that by using JS to update all the custom props, maybe pulling values in from a JSON file or something, though I've never tried that.
@crousdioll
@crousdioll 2 жыл бұрын
That's great thank you KEV
@ThourCS2
@ThourCS2 2 жыл бұрын
From thousand followers to 500k, congratulations ❤️
@17aig
@17aig Жыл бұрын
I'm very amazed with your courses videos and I've learned a lot however can you explain I've never seen you using PHP is it something we can ignore and build a website without using PHP?
@glenn_myridia
@glenn_myridia 2 жыл бұрын
Hey Kevin, thanks for the great content as always! I'd love to see your take on themes and CSS architecture in general within a React application using Emotion or Styled Components. Is this something you would consider? Thanks!
@triloksingh8596
@triloksingh8596 10 ай бұрын
You are genius 👏
@twrkhanasparukh
@twrkhanasparukh 2 жыл бұрын
Was hoping to see how you incorporate css variables in the scheme of things.
@omarakki705
@omarakki705 2 жыл бұрын
Thanks bro
@kribo9604
@kribo9604 Жыл бұрын
Is there a list of built in modules and how and where we can use them? Is there a Kevin Powel building sass modules video ?
@QuadDrums
@QuadDrums 2 жыл бұрын
This is fucking amazing, thanks for the video
@lovelynduru-magnus3233
@lovelynduru-magnus3233 2 жыл бұрын
Hello Kevin, I'm trying to keep up with all of the videos you have created and you're still making new ones.
@faulekatze3374
@faulekatze3374 2 жыл бұрын
Hey Kevin, what do you think about Bulma instead of bootstrap/grid, or do you have any videos on it? Thanks!
@jarekkubiak
@jarekkubiak 2 жыл бұрын
you got extra like for star wars t-shirt!!!
@drakZes
@drakZes Жыл бұрын
I tried this with angular, but getting an error saying the list.lenght is undefined. I have isntalled Sass and Sass loader using npm. Anyone know how to fix this.
@A_Lesser_Man
@A_Lesser_Man 2 жыл бұрын
i have to disagree with ignoring a null $bg. best to trap for that, or set a default when $bg is null.
@asterisked
@asterisked 2 жыл бұрын
Hello Kevin! For someone who's been developing for quite a long while with React Native and hasn't used common CSS in a while, would you recommend using plain CSS or SCSS for a web project? Or something different altogether? I haven't picked up web in a while so I don't know what the current state is haha Thanks!!
@KevinPowell
@KevinPowell 2 жыл бұрын
If you're going React, CSS-in-JS solutions are veery popular. I'm still a fan of creating a global stylesheet, either with regular CSS or Sass though :)
@asterisked
@asterisked 2 жыл бұрын
@@KevinPowell Seems like styled-components is the more popular, right? I remember using it in the past, will have to go through the documentation again. Having global styles along with this sounds good too. Thanks Kevin!
@JEsterCW
@JEsterCW 2 жыл бұрын
I pref using other stuff, but this is defo interesting if someone is going to make own tool for own stuff or usage, i think this is too much of work for something small, there are frameworks, ui libs and many different tools that can improve ur productivity, but its defo usefull for ppl who are constantly using sass in their projects and dont wanna use anything else cause idk for some reason lol
@eyeofthetiger7
@eyeofthetiger7 2 жыл бұрын
One thing that I'm working on right now and curious how best to go about it is a Sass architecture and implementation for Nx monorepos, which is an increasingly popular tool for building large, complex apps (mostly frontend) with multiple libraries for a given project. Could be a thing more people end up running into.
@KevinPowell
@KevinPowell 2 жыл бұрын
monorepos are definitely growing in popularity, though they're a little out of my comfort zone. I do think any well thought out design system should be able to handle anything that's thrown at it though...
@hjetwd
@hjetwd 2 жыл бұрын
Kevin please make a video about the functions and placeholders in sass =) thx
@Sam-vz7pf
@Sam-vz7pf 2 жыл бұрын
Hey Kevin, Hope you are doing fine just want to ask you i it important to install node and sass on to our computer or now it can be done by only the vs code extension live SASS compiler??? Please do answer. Thanks.
@KevinPowell
@KevinPowell 2 жыл бұрын
I strongly recommend using the node and sass through the command line and going from there (or of course, using build tools and other things, which also often use the command line as well). You can use live sass compiler, but if you do, make sure you're using the new one and not the old version of it.
@Sam-vz7pf
@Sam-vz7pf 2 жыл бұрын
@@KevinPowell Thank you so much Kevin. One last thing is there any difference between both in functionally or in other aspects??
@Sam-vz7pf
@Sam-vz7pf 2 жыл бұрын
@@KevinPowell Please if you can explain it will be a great help.
@codingwithrendi
@codingwithrendi 2 ай бұрын
I love css
@carolmckay5152
@carolmckay5152 2 жыл бұрын
🤯
@sbtoolman12123
@sbtoolman12123 2 жыл бұрын
for a guy who has JUST started to figure out grid and flexbox, this is VERY overwhelming...i think i will go back to grid and flexbox and leave this to the pros..
@whatthefunction9140
@whatthefunction9140 2 жыл бұрын
Can I do this in postcss too?
@KevinPowell
@KevinPowell 2 жыл бұрын
as far as I know, postcss doesn't do things like mixins, if/else, etc.
@whatthefunction9140
@whatthefunction9140 2 жыл бұрын
@@KevinPowell love you Kev. Can I call you kev?
@lewis4929
@lewis4929 Жыл бұрын
Didn't you say in a different vid to not use @include? Or have I misunderstood you?
@EosDoesStuff
@EosDoesStuff Жыл бұрын
You must be thinking of @import
@sawzarnilinhtay5551
@sawzarnilinhtay5551 Жыл бұрын
should we use sass/scss in future(2023)
@excelemma5960
@excelemma5960 2 жыл бұрын
Started web dev some months back😩 having so much issues with javascript need some advice from you😞
@KevinPowell
@KevinPowell 2 жыл бұрын
JavaScript is definitely not my strength! Check out Web Dev Simplified as a first stop, and Brad Traversy or Net Ninja might have some crash courses on it as well.
@excelemma5960
@excelemma5960 2 жыл бұрын
@@KevinPowell Thank you so much..i also watch Web Dev simplified
@annettelasar9347
@annettelasar9347 Ай бұрын
Is this really SASS as you keep saying? I thought you didn't use any curly brackets and semicolons in SASS. Isn't this SCSS?
How to create a theme switcher with HTML & CSS
28:21
Kevin Powell
Рет қаралды 109 М.
Stop using @import with Sass | @use and @forward explained
13:13
Kevin Powell
Рет қаралды 245 М.
ИРИНА КАЙРАТОВНА - АЙДАХАР (БЕКА) [MV]
02:51
ГОСТ ENTERTAINMENT
Рет қаралды 14 МЛН
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 4 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 20 МЛН
CSS is getting better, but Sass is still relevant
18:42
Kevin Powell
Рет қаралды 29 М.
How I make UI color palettes
8:51
UX Tools
Рет қаралды 380 М.
A deep dive into CSS color-mix()
18:06
Kevin Powell
Рет қаралды 26 М.
The different types of JavaScript functions explained
14:47
Kevin Powell
Рет қаралды 37 М.
Light & Dark mode WITHOUT CSS!
11:42
Kevin Powell
Рет қаралды 105 М.
Dealing with hover on mobile
7:07
Kevin Powell
Рет қаралды 126 М.
Stop using an extension to compile Sass
21:39
Kevin Powell
Рет қаралды 127 М.
5 Sass features that make it better than vanilla CSS
28:29
Kevin Powell
Рет қаралды 73 М.
ИРИНА КАЙРАТОВНА - АЙДАХАР (БЕКА) [MV]
02:51
ГОСТ ENTERTAINMENT
Рет қаралды 14 МЛН