Hey everyone. Uh, in this video we're going to discuss design tokens. Okay? There's a lot of talking in this video trying to explain what they are when we use them, the main reasons we use them, the difference between variables, styles and design tokens. There is a lot of arm weaving that you can't see and me explaining, but hopefully it's useful to get us kind of ready for the next video where we actually start doing some of the design tokens. But let's get started.
Let's get the arms waving. Let's go. So let's start off by making a simple design token. Okay? At the moment I've got this just basic design here. I'm hard coding the color, okay?
So this color has a stroke down the bottom of this screen. This box at the top here has the same color. That's not good because I have to then go and update all of those colors, uh, every time I wanna make a change. So we need something to represent that color and that's where a design token can be useful and that's where a design token is useful. Be warned, we've kind of done this already, so nothing selected. Let's go to local variables.
Let's create a variable, okay? A color variable. I'm gonna call mine color primary. I'm gonna give it this color. I'm gonna go and apply it. Okay?
So I'm gonna grab this box at the top here and I'm gonna say, I don't want you to be hard coded. I'd like you to use one of the styles. It's kind of not a style. Styles are down here in the circles, okay? And the variables mines are jumping around. Stop jumping there.
Is there in the square. Okay. Basically the same thing. Here we go. I've applied my color variable, AKA design token to this box so that later on it's really easy to go and update the color, especially when I've got multiple instances of the same thing. I can say local styles.
You design token are this actually because we've used a token instead of the actual number. It's really easy to go and update. You're like, Hey, is that it? There's more to it. But basically that's what it is. This here is a token K that represents this.
We use this instead of that number as like a placeholder design token, variable placeholder. They all do the same thing. They represent something else that kind of holding information inside of them. And in our case is holding color. We could create another design token. Okay?
This one could be a number and this one's going to be Border radius and we're gonna use eight. That is another design token. Really simple one. We'll get more complex, but now you're asking a design tokens, just variables. They totally are. If it's a variable that controls the design of something like spacing and padding and font and color design, token, AKA, a variable, what's not a design token, but still a variable.
Think things like there's so many more variables in the world, okay? When it comes to especially coding, okay? Uh, we did this earlier in the course. Let's look at our local variables, okay? Where we went to general, okay? Total equals value zero.
That is not a design token. Is the cart full false? No. That's a bit of logic we used for uh, creating our advanced prototype. It's a variable, but it's not a design token. Design tokens is a way of us as designers to kind of like group the things that we spend all our time doing.
Okay? Font spacing, color kind of focuses what we do with variables. But your developer will just call everything that you do. Doesn't matter if it's color or font, probably just a variable and might shake their head at you going fancy design tokens. It's just a variable. And you're like, yes it is.
But it defines our world. So we've made some design tokens earlier on. Uh, let's look at spacing still. The design token, okay, this represents eight pixels. So SM is our token. We use that instead of this to make it easy to update both in our figma design and in where our designs are being deployed, okay?
In a website, in an app so that your developer is also using this variable name so that things are consistent. So why do we use them? Kind of three reasons I think. Um, one is that it makes things a lot clearer if I'm using Border radius, okay? In my both my design and when I'm coding the website, say you're building out CSS border Radius is so much easier to understand and logical, it makes sense. Second reason is for large complex designs, we need this kind of structure so that we're not just using the color values and pixel values on everything can get unwieldy real quick.
So great for large designs and probably the most important is when you are working closely with the development team. This is probably the most important reason for using design tokens. 'cause what we can do is we can both agree both sides design and development agree on a naming convention so that they're not trying to translate what you've called color one to what they're calling color primary. If you also use color primary, ah, we all know what we're talking about. There's gonna be a lot less, uh, implementation problems. And later on when you're trying to update the design, you can say, Hey, color primary needs to be this other color.
And your developer goes, no problem. I can update that 'cause it's written right here. Color primary. So why don't we just use styles like we'd have in the rest of the course? Styles are fine. Okay?
They're very, uh, Figma centric though. There's nothing really wrong with them. The big upside of using say variables as design tokens. You can kind of use uh, styles as design tokens as long as the naming conventions are fine, okay? 'cause you've seen we've made color primary before and we've gone into color value, the developer will know exactly what you mean. But when it comes to the term design tokens, often we are referring to variables and we like variables more than styles, mainly because we can do two big things, which we'll actually do in the next video.
A lot of talking in this video. I know we need to set the ground, but I need to set the stage a little bit. So let's have a look at our one we're making in the last video. What we can't do with styles is we can't do these modes. Okay? Compact, comfortable.
That's why design tokens AKA are better fitting with variables, okay? 'cause we've got these different modes. Same with the colors that we made. Okay? We've got light mode and dark mode. Whereas in styles we'd have to go text primary light and then have another listing that said, uh, text primary dark.
Whereas this, we can just have one in these two different variable modes. The other reason we use variables instead of styles is that you can get variables to reference other variables. We'll do that in an example coming up, but styles are kind of their own thing, whereas variables can all link together and get this kind of like chain action going. That's where the design systems can get quite tricky and quite complex when variables reference other variables who reference other variables. It's also their secret power though man. You've done some talking, Dan.
Have I clarified it at all? Probably not. Let's go and actually do something in the next video and we will kind of make a little bit more sense. Hopefully you should see how much arm waving I'm doing. Can you feel arm waving to help explain it? Okay.
Uh, anyway, uh, let's get onto the next video and actually do some stuff. Put it into practice.