Creating a Button System with Nested Symbols on Sketch App

NorthGrid
26 followers
Oct 27, 2022
Hello and welcome to Sketch Together.
My name is Pablo Stanley,
and today we're going to learn how to create a button system
using nested symbols on Sketch.
This is part of a design crash course
on creating your own UI framework using Sketch.
So, for today, we're going to need
to download the resources.
There are links down there on the description.
Also, you need the latest version of Sketch
to be installed on your computer.
And also, you need the plugin called Auto Layout.
It's a pretty cool plugin.
And also, very important, we need to be ready to learn.
Okay, let's get to it.
Today, we're going to be designing a button system,
but before that, we need to understand
the power of nested symbols in Sketch.
Let me show you first what we're going to do.
Let me, up in here, all these files
are there in the description, so you can download them.
So, for example, here, we have a system of different buttons
and all of these are pretty much the same button,
just with different states.
And that's something that you can do
when you use nested symbols, which is great.
So, for example, here, this is one button
and then it has all these overrides
and then you can use nested symbols as overrides.
So, for example, this is a very complex system of buttons.
It has different shapes and different states
and icons and stuff, but then you can do
something a little bit more simpler,
where it's like probably there are not a lot
of different shapes on your buttons.
They're all square, so then you can simplify that.
And then you can go all the way to super simple,
where they're all just one color,
primary color and one secondary color.
There are no different sizes.
They're all the same size.
We're going to learn how to create this one,
the one in the middle.
They're not too complex, but not too simple.
But the files for these three systems,
you can download them.
There's a link for all of those.
So, before we get into this,
we have to understand how nested symbols work.
So, let me go over here.
I have a practice just to go over quick about it.
So, how do you create a nested symbol inside a symbol?
It's pretty simple.
You just put a symbol inside another symbol
or you just select two symbols and then create a new symbol
and that or just one symbol
and then create another symbol on top of it.
And then you have a symbol that has a symbol inside.
And then the cool thing about it
is that those symbols, you can override them later.
Rule number one, there's no limits
to how deep you can nest your symbols.
You can go as deep as you want.
It's as simple as inside the symbol.
And then you get into inception level symbol.
When you edit a symbol, if you update it somewhere else,
it will update everywhere else where that symbol
is being used, including nested symbols.
One of the rules that you need to understand
is that on your menu for the overriding,
it would only show you symbols that are the same size.
So, it's a good thing to learn.
And let's see some examples real quick
so you can see the value of this.
So, for example, here I have one symbol.
This is a cell and this cell, I have it here.
All these are the same symbol
and you can see they all have an icon, a text label
and then have another icon on the right.
Now, the thing is, let me inspect this.
I'm going to go in here, I see my symbol
and then you will see that I put also,
let me zoom in so we can see,
I put also some other icons that are symbols too
and other icons on glyphs that are this size
and they are for here, for this side.
The thing here is that all these are the same size
and all of these are the same size.
Why is this important?
Because over here, when I want to override a symbol
inside this symbol, I can override it here on the menu
by selecting only the ones that are that size.
So here, on my override of this symbol,
you see that I only see three symbols?
That's because those are the only ones that are that size.
So I can override it with this, I can override it with this
and then the symbol, the icon on the left,
I can override it only with these
because in my symbol library,
those are the only ones that are that size.
Very important.
And the cool thing here is, see, now I can say this is,
let's say that this is favorites, favorites,
and then this override is settings, that's good.
But you know what?
Actually, I don't want to have any on the right as selected.
So I'm going to remove that symbol.
And then over here, this is going to be,
let's say that instead of settings, it's going to be avatar.
So this is going to say account.
So you can start realizing how cool this is
where probably let's say that there's something going on
on the account, sorry, some information on the account.
So you can start seeing like when you're building a menu,
when you're building something
that you're going to be repeating a lot like cells,
you get to use a symbol inside symbol,
and then you update it in one place
and it updates anywhere else.
So let's say, for example, I go in here
and then I don't know why,
but let's say that this icon is over here too.
And then the label, it moves over here.
Let's keep it at 16 pixels.
And then if I return to my instance,
see how everywhere else where that symbol is being used,
it was updated.
Another example, for example, a navigation bar,
when you are selecting one thing and then another one.
So some of the options are not selected
and one option is selected.
And then when you tap on something else,
then that one becomes selected
and the other ones are not selected.
So over here, I have albums selected as you can see here,
but I want to create another bar
for probably another example
where I want a radio to be selected.
So I can just really easily just go over here
and say this one is selected
and then albums is not selected.
Or let's say that search is selected.
Sorry, search is selected
and then radio is not selected, right?
And there you go.
So you start seeing the power of this is really cool.
So you can start building a system with nested symbols
that you're going to be reusing across your documents.
Okay, that was a quick introduction into nested symbols.
Now let's see one example of the buttons, how we did that.
Okay, I'm going to open the file
that is called button simple, buttons simple.
So you can open this one
and then you're going to see here,
oh my God, so many buttons, right?
So many states of this same button.
The cool thing here is that there are actually
not a lot of states once you see the symbols.
So I'm going to double click on any of these
and then you're going to see here,
I put some labels there
so you can understand what's going on.
I have number one, I have the colors.
The colors that I'm going to be using across my buttons.
And these colors can actually be used across other icons
or other elements across your document.
And then here I have button sizes.
Since the size of the text, it's different
depending on the button size, at least on this system,
I've created different button sizes.
I create one button size, one button size, one button size.
And inside this one, let me zoom in, inside here,
you're going to see that I have my CTA,
which is going to be, I'm going to be able to overwrite it.
And then I have the state, the state of the symbol.
I'm going to explain that.
And then icon, and then the color.
The color is being pulled from these symbols.
And then the state.
The state is being pulled from these symbols
that are also the states.
So over here, I have one symbol that is a state hover,
state slash hover.
And this one, all it has is just one square inside
that is a full width and it's a white shape
with 20% opacity.
That way, when I put it on my button,
then I have my primary color in one layer.
And then on top of it, I have my state on top of it.
And my state will determine that it's the primary color
plus 20% opacity white,
which makes the primary color 20% lighter.
And this is something that actually
you would do on CSS on LESS or SAS.
You just have one primary color
that is being affected by different states.
So for example, the pressed state
is actually a black color at 20%.
So I select this and you're going to see here,
it's black at 20% opacity.
That way, that state is going to be my primary color.
And then on top of it, it's going to be 20% black.
And now I have a pressed state.
And another one is disabled.
Disabled is a little bit trickier
because I added two things.
I added first a layer that does saturation,
that is black and saturation.
That way, whatever is below it,
it will turn it into gray.
And also I added another fill that is white at 70%.
That way, it's not only unsaturated,
but also creates really light
and it's just almost like it's faded away.
So I have that.
And then I have some icons,
some glyphs that are, right now there are 24 pixels,
the width of them,
and they're all going to be overwritable
on my main button.
So I have all my elements here.
And then something that is really important
when you're creating your symbols here
is how you position your elements.
So for example here, I have my text layer.
And my text layer, I want it to be resizable.
Well, I want it to be floating in place
or you can use resizing.
I prefer floating in place.
That way, if I make it big or small,
if I change the height of it,
it will still be in the middle
and the vertical middle of the button.
But I also use auto layout, my plugin.
It's over here.
And here on the plugin, on the auto layout plugin,
I pin it to the left and to the right.
That way, it will grow with my button.
It won't just be center in the middle,
but it will also be resizing.
That is one way to do it.
Another way to do it will be that here
on my resizing options,
I set it as resize object.
And then here on my auto layout,
instead of pinning it here,
I only center it in the middle.
And that way is combining resizing with floating.
So again, it's really cool to combine
the native positioning and resizing for objects
and then combine it with the auto layout option,
which is pretty cool.
Then you want your icon.
My icon, I have it here.
Let's have it as just as floating place
because I don't want it to be resizing.
I just want it to always be in the center.
So I have it here as floating place.
And then I have my color,
my color layer, which is calling from this.
I have it as a full width
and I want it to stretch just like up and down,
just stretch.
And also the same for my mask.
So here's the thing with the mask.
Since I have my states over here
and these are just squares,
I want my mask, I put a layer all the way to the bottom.
And this is just masking my contents.
It even is masking my states.
And it's just a eight pixels or rounded radius.
And then I just put it as a mask.
So anything else that is on top of it is getting inside.
And that's it.
Now let's see how on the example it works.
So over here, I have all my different states
for the large buttons, the medium buttons
and the small buttons.
And all of these are the same symbol.
All of these in this row are the same symbol.
The same over here.
This is the same symbol as these ones.
The only thing that is different
is that I changed the color over here.
So let's actually, let's preview one.
So I'm going to go over here
and I'm going to put a symbol, a button.
I'm going to put a medium button.
I put it here.
And by default, it will have the icon and the CTA visible.
But you can just like hide one of them.
You know what?
I'm going to, for this one,
I'm going to hide the icon.
So I go to the icon folder here
and I'm going to say none.
That's one of the cool things too.
When you don't need to override anything,
you can just select none and it disappears.
So I have my button here and I want to change my CTA.
So let's go.
There you go.
And then I want to change the hover,
sorry, the state of it.
So let's say that I have another state here
and this one is going to be,
well, by default, it's already selected state as hover.
And I want one that is not hover.
So this one, I'm going to say none.
So there you go.
That's my primary button with no state on it.
Then here is on hover.
And then over here,
I'm going to add another one that has a pressed state.
So it's a little bit darker.
And then I'm going to add another one.
It's the same symbol, I'm just duplicating it.
I'm going to add another one
and this state is going to be disabled.
And now it turns really light and also grayed out.
And I'm going to add another one.
I'm going to just duplicate this one over here
with eight pixels.
And then this one, I'm going to say,
hey, you know what?
This one doesn't have a CTA
because this is going to be loading.
So I just press one space here on the CTA.
And then here on the icon,
I'm going to select the loading icon.
But I can select any of the icons.
You know what, when there's a success
or when, I don't know,
there's something happy happen,
I can select that one or a warning.
And then here on the colors,
for example, the warning one,
I'm going to duplicate this one here.
So probably on the warning one,
you actually want to change the color of it.
So that's the cool thing about this.
If you have a color, you can say,
hey, you know what?
Instead of primary color,
I want to use a warning color.
Since that's a symbol too,
I can just overwrite it.
And there you go.
So this one is going to be happy,
very happy.
And this one is going to be like,
there's something wrong going on.
So that's it.
That's how you use the files
that I put there in the resources.
But let's actually create ours.
Let's create a system really quickly.
If you already understood everything,
you can stop this video
and you can just download the resources
to inspect them and then create your own.
But if you want to follow me when we create one,
stay tuned, let's do it.
Okay, so I created a new document.
And here on the new document,
I also just imported some icons
that I'm going to be using on my buttons.
If you want to get the blank document,
there's also a link to the blank document
that only has the icons
and you can start designing with me
if you want to follow up.
So here, the first thing that I'm going to do
is create colors.
I know, where are we creating buttons, Pablo?
I know, I know, but don't worry.
We're going to be using these colors across our buttons.
So it makes sense.
So I'm going to make these,
let's say a 40 pixel palette
and I'm going to add a blue to it.
This is going to be my primary color.
Then I'm going to duplicate it
and let's do another color.
It's going to be my, I don't know, my secondary color.
And my secondary color is going to be
probably a little bit lighter.
Same blue, just a little bit lighter.
And then this other blue is going to be
a little bit more bluer,
a little bit bluer, if that makes any sense.
Okay, I got it.
I got my two colors.
Let's add another one.
And this one is going to be my success color,
like a green when something good happens.
So I'm going to go over here to my green.
There you go.
Nice, really saturated green.
It's very happy.
And then over here,
I'm going to add another one that is like a warning.
Something's going wrong.
So it's going to be like an orange,
like a reddish orange around there.
And that's telling me, hey, something's wrong.
So I have my colors here.
And now I want to create symbols out of these colors.
I know, it sounds kind of weird,
but it's going to make sense later.
So I'm going to, this shape,
I'm going to create a symbol.
I'm going to call it color slash,
or you could call it palette, whatever you want,
slash, and then primary.
Since I'm going to be using this,
I'm going to just copy color slash.
And I save it, I create a symbol of this.
This is going to be secondary.
This is going to be success.
And this is going to be warning.
If I go to my symbol space,
I'm going to see all the colors here.
I'm going to probably, good thing to do,
good practice is just like arranging your symbols
in a nice way.
That way later you can reuse them
and see how everything is laid out.
So I don't need them here.
Actually, I'm going to get rid of this
and I'm going to reuse this.
This is going to be the background of my color.
So I'm going to make it 40 pixels.
Let's make it actually 38 pixels.
I'm going to add a text layer
and it's going to be just a text layer.
I'm going to put it in the center.
So line it here and there.
And then I'm going to make this a little bit smaller.
There you go.
So now the thing is this,
since this is a symbol already,
if I wanted to add a corner radius,
I will need to add a mask below the symbol.
So I'm going to add another rectangle
and this is just going to be my mask
that is going to be masking the corner radius
on my primary color.
So I'm going to add a, I don't know, what do you think?
Let's do 20.
Let's do a rounded, a very rounded.
So there you go.
And now I'm going to move it below the color.
I'm going to call it mask.
Oops.
And I'm going to make it a mask.
There you go.
So now I have all of these three layers.
I have my text layer,
I have my color, and I have my mask.
All I'm needing now is the icons,
the icons on top of it, right?
So, but before we do that,
I'm going to just create a symbol
out of these three layers.
So I select those three layers and I create a symbol
and I'm going to call it button,
button slash, and then this is going to be,
what do you want to call it?
Medium, because we're going to create
different sizes of the same button.
So button medium, I press okay,
which should be good.
And now I'm going to double click
and I have my button here, right?
Pretty cool.
And now I need to start adding states to it.
Different states, like the hover state,
the pressed state, the disabled state.
And for that, I'm going to actually create
another symbol over here
that's just going to be for the states.
And this can be a rectangle, whatever size,
whatever size, I'm going to put it here.
I'm going to change to the white color
and I'm going to make it 20%.
The thing is this,
you want your symbols to be a specific size,
the ones that are related.
That way you group them.
So for example, this one is going to be a 22 pixels by 56.
It's a really weird size.
So I don't think I'm going to be reusing it again.
I'm only going to be using this size
for my states symbols.
So I have my rectangle
and I'm going to create a symbol out of it.
And it's going to be called state slash hover.
If I zoom out, I'm going to see it here.
Now it's here.
This is just an instance of the symbol.
And this is the actual symbol that I can edit.
So I'm going to go over here and delete the symbol
and the actual symbol that I have is here.
This is a symbol.
And I have here my rectangle,
the rectangle that I just edited.
And now I'm going to actually duplicate this one.
And this one, instead of state slash
hover, which is going to be called state pressed.
And since I duplicated it inside the symbols page
and I duplicated the artboard that was a symbol,
then it just created another symbol.
So it's not a new instance of the same symbol,
it's a different symbol now.
So here, this layer, instead of white,
I'm going to turn it black.
And that way, once it's on top of it,
it's going to be a little bit darker, my primary color.
So I have my pressed state.
I'm going to add another one in this rectangle.
I'm going to call this one, sorry,
I'm going to call this symbol disabled.
Disabled.
And then on this rectangle,
I'm going to change it back to white.
But instead of 20%, I'm going to make it 70%.
Really light, it's going to be really light.
And then I'm also going to add another fill
to the same shape.
I'm going to add another fill.
And this one is going to be a solid fill.
I'm going to, whatever.
It can be whatever here, white or black.
It just has to be a desaturated color.
I'm going to put it black, just so we can see it.
And then here, I'm going to change the opacity.
100% is okay.
But here, the blending mode, instead of normal,
I'm going to change it to color.
And then I'm going to move it below.
That way, it's below the actual lighting.
Okay, so I have it.
I have my disabled state.
And you're going to see what happens later.
So now I'm going to go back to my button symbol.
And here in the button symbol,
I'm going to insert an instance of this state symbol.
I'm going to go to symbol, state.
I have it here.
And I'm going to insert the hover state.
I just put it here inside the symbol.
So now it's nested inside that symbol.
That's cool, right?
I'm going to just move it to the size of the whole symbol.
And since there's a mask below it,
that mask is also capturing that state.
And as you can see now,
this hover is on top of the primary color.
So now the 20% opacity white is on top of the primary color.
And now I have my hover state there.
Right next to it,
I'm going to insert an instance of that same symbol.
It's over here.
This is where I added it.
This is where I preview it.
So here, I see that I have now as an override here a state.
I can say pressed.
I can say disabled.
Or I can say none.
And that way, it's just a button that is there.
But if I wanted to change it back to hover,
I can just select it,
and now it's hover state.
How cool is that?
And also, I can change the color of it.
Instead of primary,
let's say that it's a secondary button,
or it's a success button,
or it's a warning button.
I'm going to keep it in primary.
You're starting to see how cool this is, right?
Awesome.
So now the next thing that I want to add
is the icons on top of them.
So I'm going to go back over here,
and I'm going to turn these layers into symbols.
So I'm going to select it.
I'm going to select this one first,
and I'm going to create a symbol.
I'm going to call it glyph slash success.
Okay, and I'm going to copy this glyph
just so I can reuse it again.
And this one is going to be called glyph slash love.
And this one is going to be called glyph slash warning.
There you go.
I'm going to go back to my symbols page,
and I have them over here.
I'm going to select these hard boards.
I'm going to put them over here.
Here are my symbols.
I'm going to arrange them just so they're nice and tidy.
And the color of these shouldn't be gray.
These actually should be white.
So I'm going to select these, the actual layers.
I'm going to press Command, and then just drag,
and I select all the layers,
and I can change the color of it back to white.
And right now I cannot see the shapes,
so what I can do is select the hard boards,
and I can add a background color to it.
I can add a gray background color to it
so I can preview them,
but I also, I want it not to include it in the export,
so I'm going to disable that.
That way, it's only for previewing here,
but whenever I use an instance of the symbol,
the background will not be there.
Okay, cool.
So as you can see, that's cool.
My symbols are there, but they're all different sizes.
So what I need to do is select these hard boards
and make them all the same size.
So I'm going to make them 24 pixels,
or no, actually 16 pixels?
No.
Yeah, 24 by 24.
24 by 24.
Now I have them all the same size.
That way, I will be able to overwrite them later,
and I want to center them to the artwork.
So I select this, center and center, center and center.
There you go.
Now I have my icons
that I'm going to be able to overwrite later,
but I still need it to be part of the symbol over here,
of the button symbol.
So I'm going to insert an instance of it.
I'm going to go to glyph, love.
I'm going to put it in the center, right there.
Now it's part of the symbol.
I'm going to put it all the way to the bottom
on top of the primary color.
I'm going to center it,
and I'm going to change the resizing to float in place.
And while I'm at it,
I'm actually going to change for everyone else.
So this one should be,
the text layer should be the size of my symbol,
and it should be float in place.
And now, so here's the thing.
I can say, hey, resize my object.
And then here on auto layout, I want it to be floating.
So that's a combination.
I was telling you why you want to use auto layout
and the native resizing options.
So now that it's on resize,
it will resize with the shape of,
with the size of the artboard.
But also since I used over here,
I put it in the center here on auto layout
and in the center here, horizontally, vertically,
it will always be in the center of my button.
So that's why we needed to have the auto layout plugin.
Okay, we're ready.
Let's test it out.
We have it here actually.
And I can say, hey, you know what?
This one, instead of the lob,
sorry, instead of the lob icon,
I want it to be success icon.
And then here, I'm going to change the success color
and no CTA.
I'm going to press just space here on the CTA,
on the text.
And there you go.
The same symbol,
but you're able to do all these overrides
that allow you to create a button framework,
a button system with nested symbols.
How cool is this stuff?
Now, what you can do is create different sizes
of the same symbol.
So for example, this one,
I'm actually going to duplicate it.
And over here, the same symbol,
but I'm going to make it a little bit bigger.
So that way I have a big button too.
So I'm going to call this button big.
And then this one,
I'm going to change the size of the artboard
to instead of 38,
I'm going to change it to 48.
Super big button.
See how Auto Layout automatically put it in the center?
It's cool stuff.
Really cool stuff.
I'm going to make it this,
my hover state, the size of the artboard.
I also want my primary to be the size of the artboard.
There you go.
And I want my mask to be the size of the artboard too.
That's what's keeping everything in the center, right?
And then I'm going to put my glyph,
my icon center in the middle.
And there you go.
I'm going to make it also a little bit bigger here.
Now I have same button.
It's the same instance.
It's all the same elements.
I just made it a little bit bigger.
That way over here,
if I want to,
I'm going to go over here.
And if I want to insert a button,
I can insert a button that is big
or one that is a medium.
So I'm going to insert a button that is big.
I put it here.
And then this one,
instead of a medium,
I want it to be big so I can change it anytime.
Big.
Oops, sorry.
Over here, sorry.
Here, instead of button medium,
I'm going to say button big.
Now it changes,
but I'm going to right click on it and say A,
set to original size.
And then it changes to the original size of the button.
Cool stuff, right?
So now you can start building your system
where I'm going to select this one.
I'm going to remove the,
sorry.
I'm going to remove the glyph.
I'm just going to say none.
And then I'm going to create different instances of it.
First is none.
Going to duplicate it.
Duplicate it many times.
And then here I have a state hover.
Over here, state pressed.
And here, state disabled.
And on these ones,
I'm going to make it 1, 2, 3, 4.
This one is going to be a glyph.
This is all of these.
The CTA is nothing.
That way I can insert icons.
And this one is love.
And this one is warning.
Cool stuff, right?
How cool is this?
This one I'm going to change the CTA to hover.
That way people can understand what's going on here.
This one to pressed.
And this one to disabled.
And over here,
this one I'm going to change the color.
Instead of primary,
I'm going to change it to success.
This one I'm going to keep it like that.
And this one I'm going to change it to warning.
Something wrong going on.
It's cool stuff, right?
Really cool stuff.
I really, really like this.
Going to duplicate this.
Just so we can see it.
And then I can change this to button medium.
And then when you change it,
it doesn't really give you all the same instances.
The only instances that it overrides,
that it keeps are the text overrides.
So all of these are the symbols.
I actually don't want it to have an icon.
So I can say no icon.
And then over here,
I can say this no one.
And then, oh, before we continue,
actually, I want to say set to original size.
Now they're a little bit smaller, right?
And then this one, this cover is already good.
This one should be pressed.
This one should be disabled.
And just the same, the same as before,
over and over.
But once you have it, it's pretty cool, right?
So I have my system here.
And now the cool thing here,
I have my system,
but whenever something changes,
you know what?
Tomorrow, hey, you know what?
That primary color should change.
It shouldn't be that blue.
I don't know.
We changed our style guide,
and now it should be red.
You change it in one place,
right here, you change it,
and you go back over here.
Let me go back to my page.
And you see it changed everywhere else
where that color was being applied.
And here on the states,
on the hover state,
it's still that same primary color that now changed,
but with a different color in the background.
But the hover is still the same,
where it's 20% a little bit lighter.
On the press, it's 20% a little bit darker.
The disable is still gray.
It's the same.
Cool stuff.
I hope you see the value on all this.
I would love to see your creations too.
I have a Facebook group
that is called facebook.com slash groups sketch together.
And you can share with the community
the things that you have created.
Also, people usually ask questions,
and we're all there to help.
So you should join our Facebook group.
It's pretty cool.
We talk about design.
We don't just do design talk.
We talk about design.
We don't do design talk.
Very different.
That's it.
Subscribe, like, all that stuff.
Thank you.
Love you.
See you on the next one.
