Class HStack


public class HStack extends Stack<HStack>
A horizontal stack layout container that arranges children in a row.

HStack uses CSS Flexbox with flex-direction: row to lay out child elements horizontally from left to right. It provides convenient methods for controlling spacing, alignment, and distribution of children.

Features:

Usage:


 // Simple horizontal button group
 HStack buttonGroup = new HStack();
 buttonGroup.setGap(8);
 buttonGroup.addElement(new Button("Save"));
 buttonGroup.addElement(new Button("Cancel"));

 // Centered navigation bar with space between
 HStack navbar = new HStack();
 navbar.setAlign(AlignItems.CENTER).spaceBetween();
 navbar.addElement(logo);
 navbar.addElement(menuItems);
 navbar.addElement(userProfile);

 // Centered content with gap
 HStack centered = new HStack().center().setGap(16);
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • HStack

      public HStack()
      Constructs an empty horizontal stack.
    • HStack

      public HStack(int gap)
      Constructs a horizontal stack with the specified gap between children.
      Parameters:
      gap - the gap in pixels between child elements
    • HStack

      public HStack(String gap)
      Constructs a horizontal stack with the specified gap between children.
      Parameters:
      gap - the gap value (e.g., "1rem", "16px")