Stacks in Adobe XD enable objects within a group to define fixed spaces between them. When you resize, reorder, or modify objects within a stack, XD automatically preserves the defined space between objects.
Coupled with padding and responsive resize - stacks make a powerful feature combination that provides more control and speed in design. Stacks applied to components, automate layout, and makes editing of buttons, menus, dropdowns, card-based layouts a breeze.
- If you hover an element with a hover state that grows in size, the background does not resize to fit the new state, and elements in the stack are not pushed away.
- Components cannot act as a background for padding and stacks. Instead, create one component that contains both the content and the background.
- You cannot:
- Convert special groups into masks or Boolean groups into stacks.
- Resize stacks in the stack direction.
- Select a stack element and elements outside of the stack.
XD automatically determines the stack orientation based on the structure of your group or component. However, if you want to change the stack orientation, select Vertical or Horizontal within the Stack option in the Property Inspector.
When working with components, the stack orientation control is available only for the master component.
When you enable stack, XD does the following:
- Automatically identifies the background (a group or shape positioned at the bottom of the Layers panel and overlaps on the canvas with all the objects in the group),
- Enables and calculates the padding values,
- Determines the stack orientation: Vertical or Horizontal,
- Groups overlapping elements to preserve the layout, and
- Defines and fixes the spacing values in-between the elements.
- Select the stack elements and drag them along the stack direction on canvas.
- Use Cmd+ ] and Cmd + [ to move up and down in the stack and Cmd+Shift+] and Cmd+Shift+[ to move the selection first or last in a stack. These commands are also available in the contextual (right-click) menu.
- The new position of the stack element is highlighted with pink boxes. To maintain alignment when reordering, press shift to lock the stack elements in the drag direction and preserve their original alignment.
When you create a stack, XD automatically determines the background. However, when you enable stacks on a group or component, the layer or group positioned lowest in the stack that overlaps its content, becomes its background.
- Create a shape or group inside the stack that acts as a stack background. You can also create a background outside the stack and copy into the stacked group.
- From the stack, select the element you want to use as the background.
- Right-click and select Make Background or Replace Background. The selected element is moved to the end of the stack and resized to fit the size of the stack and padding values.
Now that you have learned how to create stacks and work with them, here are some additional pointers on using stacks:
- You can achieve a well defined and easy to edit layouts when nesting stacks within one another – for example, a horizontal stack into a vertical stack. You can nest an unlimited number of stacks. Watch the animated illustration to understand how nested stacks work. For example, if you have a card stacked vertically with an image and text fields and a button with an icon stacked horizontally, change the text in the button to view how the card reacts. You can also change the text in the card or resize the image and view all the content including the button move accordingly.
- You can combine stacks with repeat grids to create tabular columns or lists and populate them in minimal turnaround time.
You can apply stacks and padding to components to define reusable UI elements in the context of design systems. When working with components that need a label or a row update, usage of stacks makes the layout of the component react to change and automates manual layout effort. For example, if you have multiple instances with content overrides, use stacks to edit and manage spaces globally. No more manual editing of each card!
Stacks applied to master components are automatically applied to all its instances and states. You can also create a linked component with stacks and edit them.
- A space override occurs when you manually edit the space between two elements of a stack in an instance or state. If you modify the space in the master component, the changes are not applied to the instance or state.
- Instances can have content or layout overrides on elements such as a larger area text. These instances can still be in sync with the master for the padding values or spaces in-between them.
"Coupled with padding and responsive resize -- make a powerful feature combination when you’re working in a design system. When stacks are used on a master component, any instance of that component will respect that stacking structure."— Dani Beaumont, Principal Product Manager, XD.
To learn more about getting started with stacks in components and groups, watch this video.
Viewing time: 1 minute.
We've got you started on how to use stacks to define spaces between elements. Take a step forward and learn how to create animated prototypes and share them with designers or stakeholders for feedback.