In addition to adding and removing objects within a component, you can also nest components inside of one another, and this is where things really start to get interesting. Here in Step 3 I have an artboard that has a number of master components on it. I'll go ahead and zoom on in so I can see that artboard a bit more clearly.
I'm going to switch over to the Assets panel and what I have here are a series of individual components. You can see when I roll over them that they're defined as individual component icons. Below that I want to create a second set of components but I want them to sit inside of this purple circle there towards the background. To do that what I've done is nested one component inside another, so I took the plus sign -- in essence individual component -- I placed it inside the circle, and then I saved that out as a master parent component.
What I can do now is easily replace that Center component as I duplicate out this individual icon set. So I'll come on in and select these two icons here, and from here I'll hold down Option on the Mac or Alt on Windows, and just press and drag a second, and let's go for a third duplicate of that icon set. I'll zoom in even more tightly so that I can see a little bit more detail. From here let's just go to the Layers panel real quickly. Notice that if I click on this first icon I have a component that's been defined, nested inside of it another component. It's the plus sign icon that I have here towards the top; it's just been placed inside of that parent component.
When I want to replace one component with another, it's important that I have the component that I'm looking to replace selected and I can see that this one is selected because it has the green selection highlight, and I can see the diamond in the upper left-hand corner. What I want to do now is switch back over to the Assets panel and here in the components area I'm going to change the view to be a thumbnail view it makes looking at these a bit easier. Now these are all white on a colored background, so it's a bit tough to see but I've got the plus sign selected here I want to replace it with let's say the closed box icon. For that I'm going to press and drag it onto the canvas. Notice I get a plus sign letting me know I could drop it there on the canvas if I'd like to. What I want to do is roll over that nested component until the icon changes to an arrow. Once I see that arrow when I release it's going to replace that individual icon with the one that I dragged over.
Because this is a master component it's changed each of the instances here on the right. I can always come into an instance and click on it to select it and grab a different icon -- let's say the arrow icon. Once again I'm going to press and drag but rather than release right on the canvas I'm going to make sure I roll over that selected nested icon and when I release it will replace the closed box with the arrow. Now the good news is because these are instances of a master component, I still have that same behavior that you saw earlier in this tutorial. I can come in to this parent component and just select the background fill color and perhaps change it to something different. So with the eyedropper tool perhaps I want to go with a shade of green. Changing that color is going to not only change the background color of the master component, but the background color of any of the instances that I've created here on the design canvas.
Now that I've explained how nested components work, let's look at how you can easily swap them out in the next step of this tutorial.