Stack

Android · iOS · Web
Use to lay out a horizontal (or vertical) row of components or to achieve no-fuss horizontal/vertical layout composition.

Overview

The Stack component is a layout utility that arranges child elements in a vertical or horizontal sequence with consistent spacing and alignment. It provides flexibility for creating structured layouts by abstracting away manual spacing and alignment, ensuring responsive and consistent designs across platforms.

Live demo

Item 1
Item 2
Item 3
Item 4
Item 5
Modifiers

Usage

Do

  • Use the Stack to organise related elements in a vertical or horizontal layout with consistent spacing.

  • Leverage the alignment and verticalAlignment properties to control horizontal and vertical alignment of child elements.

  • Apply core space tokens to define gaps between items for consistency with the design system.

  • Use responsive properties to adjust direction, alignment, and spacing for different screen sizes.

Don't

  • Avoid using the Stack for complex grid layouts; use a dedicated grid component for multi-dimensional layouts.

  • Do not set excessive spacing between items that disrupts visual hierarchy or usability.

  • Avoid forcing the Stack to handle scenarios better suited for single-use, custom layouts.

Placement

  • Use the Stack wherever elements need to be grouped logically, such as in forms, button groups, or navigation sections.

  • Ensure the Stack aligns with other layout components to maintain a consistent visual hierarchy.

Properties and Behaviours:

PropertyDescription
OrientationDefines the direction of the Stack: vertical or horizontal.
AlignmentAligns child elements horizontally (e.g., left, center, right).
Vertical AlignmentAligns child elements vertically (e.g., top, center, bottom).
Gap/SpacingDefines the space between child elements, using design system tokens for consistency.
ResponsiveSupports adjustments to direction, alignment, and spacing based on screen size.
Flex WrapHandles overflow by wrapping child elements onto a new row or column as needed.

Accessibility

  • Ensure the Stack does not interfere with keyboard navigation or focus order.

  • Use semantic grouping (e.g., div or section with ARIA roles) when the Stack groups related content for better assistive technology support.

  • Verify responsive behaviours maintain usability across devices and screen readers.

Platform-Specific Guidance

Web

The most flexible implementation, supporting all properties and behaviours.

Android and iOS

Support core functionality like orientation and spacing but may have limitations (e.g., both horizontal and vertical alignment simultaneously). Use platform-specific guidelines to optimise for native behaviours.