User Guide Cancel

Work with nested components in Adobe XD

Learn how to work with nested components across design systems in Adobe XD.

Building a design system requires the ability to create components at the molecular levels for optimal reusability and flexibility. When creating components, XD lets you nest them within each other and create complex objects such as menus, card-based layouts, and many more. 

Read on to learn how to create and use nested components for a seamless design experience.

Components
Work with nested components in XD

Before you proceed

Be familiar with these concepts:

Component terminology

Let's first get familiar with some terms associated with nested components:

  • Main component: A main component is the component that defines and controls all component properties.
  • Component instance: A component instance is a copy of the main component and inherits changes made to the main component.
  • Nested component: A nested component is a component inside another component.
  • Outer component: An outer component is a component that has another component inside it.

Create a nested component

Using nested components, you can build more robust design systems. When you update a main component, all its instances receive the update, even if the update was done to a component nested inside it.

To create nested components, you can use any of these approaches:

Approach A: Copy-paste a component instance to a group and convert it to a component.

  1. Create a main button component.
  2. Copy-paste an instance of the button component within a group.
  3. Select the group and convert it to a component. 

Approach B: Copy-paste a component instance inside an already existing component.

Paste an instance of the Button Component inside the group

  1. Create a main button component.
  2. Copy-paste an instance of the button component within another component.

Approach C: Drill down into a part of a component and convert that into a component.

  1. Create a main dialog component.
  2. Drill down to a button inside the component.
  3. Convert the button into a component.

Example

Let’s use Approach A to create a dialog component.

Paste a button instance

Paste the instance

Paste an instance of the button component inside the group.

Convert into a component

Make the Component

Select the group and make it a component.

Create a button component

Create a button Component

Create a button component for the dialog.

Create a dialog container

Dialog container

Create a dialog container with text and other objects inside, as a group.

Best practices

Here are some best practices when creating nested components:

  • You can create a component with multiple components nested inside. However, when components have multiple states with many objects, performance can take a hit. In such cases, to achieve optimal performance, you can nest components three levels deep at most, and limit the number of states per level to a maximum of ten states per component.
  • Do not nest a component within itself. This might result in an invalid component since components are self-referencing.
  • If you have a nested component with multiple states in an outer main component, you can switch the state of the nested component. The state change then propagates to all the outer component’s instances.

Nested components syncing

With nested components syncing, changes made to components nested within a main component propagate to all the instances of that main component. 

Let's see how that works. 

Example 1: A button inside a container that receives changes from the main button.

  1. Create a button as the first main component.
  2. Nest an instance of the button inside a toggle menu.
  3. Nest an instance of the toggle menu inside a container.

Any changes made to the main button component propagate to all the buttons nested inside the toggle menu and the container.

Paste an instance of the Button Component inside the group

Now, create two instances of the main button, two instances of the main toggle menu, and an instance of the main container.

Let's look at some scenarios:

Scenario 1:

Scenario 1

Change the color of the button nested inside the main toggle menu to blue. 

All the buttons nested inside the toggle menu's instances and inside the containers got the color change to blue.

However, the two instances of the main button don't change color. This is because changes to nested components are contextual to their containers. The color change only applies to instances of the button inside the toggle menu. 

Scenario 2:

Scenario 2

Change the color of the button inside the main container to pink. The button inside the container's instance will also turn pink.

Notice that the other buttons don't get the color change. This is because changes to nested components are contextual to their containers. The color change only applies to instances of the button inside the toggle menu within the container. 

Scenario 3:

Scenario 3

Change the color of the button nested inside the container instance to green.

None of the other buttons get the green color change because this change was made on an instance, not a main component, as an override. 

Scenario 4:

Scenario 4

Continuing from scenario 3, change the color of the button nested inside the main container to violet. 

The container instance's nested button does not change color because it already has an override.

Things to watch out for

  • Nested components cannot be main components. So, if you need the change to be on the main component, right-click the nested component and select Edit Main Component
  • If a nested component in an instance of the outer component is swapped, Reset to Main State on the main's nested component will not change the instance with the swapped component. 

Best practices

Here are some best practices when working with overrides in nested component instances:

  • To create a variation of the component for reuse, create a state in the main component rather than an instance with overrides.
  • While overriding instances, ensure that you override the property that does not need updates from the main component. For example, in a button component, overriding the text ensures that the label can be different, but the size and color are still in sync with the main component.

Creative Cloud Libraries help you distribute your design system styles and components to be reused consistently across your documents. To build and distribute a design system through Creative Cloud Libraries, curate your design system assets by adding colors, character styles, and components to the Document Assets panel, and publish them as a library to reuse across all your XD and other Creative Cloud applications. For more information on how to use Creative Cloud Libraries, see Work with Creative Cloud Libraries in XD.

Frequently asked questions

In the previous versions of XD, changes made to a nested component did not update across instances of the outer component. To get an improved experience, open your documents in the latest version of XD.

Learn more

To learn more about nested components in XD, watch this video.
Viewing time: 10 minutes

What's next?

We've got you started on how to work with components in XD. Take a step forward and learn how to share your designs with designers or stakeholders for feedback.

Have a question or an idea?

ask the community

Have a question to ask or an idea to share? Come and participate in Adobe XD Community. We would love to hear from you and see your creations!

Get help faster and easier

New user?