Class Divider


public class Divider extends StyledElement<Divider>
A visual divider line for separating content horizontally or vertically.

Divider renders as an <hr> element for horizontal dividers or a styled <div> for vertical dividers. It provides convenient methods for controlling thickness, color, and spacing.

Usage:


 // Simple horizontal divider
 VStack content = new VStack();
 content.addElement(section1);
 content.addElement(new Divider());
 content.addElement(section2);

 // Styled divider
 Divider styled = new Divider();
 styled.setColor("#e0e0e0").setThickness(2);

 // Divider with margin
 Divider spaced = new Divider();
 spaced.setMarginY("1rem");

 // Vertical divider in horizontal layout
 HStack row = new HStack();
 row.addElement(leftPanel);
 row.addElement(Divider.vertical());
 row.addElement(rightPanel);

 // Vertical divider with custom height
 Divider vdiv = Divider.vertical();
 vdiv.setHeight("50px").setColor("#ccc");
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Divider

      public Divider()
      Constructs a horizontal divider with default styling.
  • Method Details

    • vertical

      public static Divider vertical()
      Creates a vertical divider for use in horizontal layouts.
      Returns:
      a new vertical Divider
    • horizontal

      public static Divider horizontal()
      Creates a horizontal divider (same as default constructor).
      Returns:
      a new horizontal Divider
    • setColor

      public Divider setColor(String color)
      Sets the divider color.
      Overrides:
      setColor in class StyledElement<Divider>
      Parameters:
      color - the color value (e.g., "#ccc", "rgba(0,0,0,0.1)", "gray")
      Returns:
      this Divider for method chaining
    • setThickness

      public Divider setThickness(int thickness)
      Sets the divider thickness.

      For horizontal dividers, this sets the height. For vertical dividers, this sets the width.

      Parameters:
      thickness - the thickness in pixels
      Returns:
      this Divider for method chaining
    • setThickness

      public Divider setThickness(String thickness)
      Sets the divider thickness.

      For horizontal dividers, this sets the height. For vertical dividers, this sets the width.

      Parameters:
      thickness - the thickness value (e.g., "2px", "0.5rem")
      Returns:
      this Divider for method chaining
    • setMarginY

      public Divider setMarginY(String margin)
      Sets vertical margin (top and bottom) for horizontal dividers.
      Parameters:
      margin - the margin value (e.g., "1rem", "16px")
      Returns:
      this Divider for method chaining
    • setMarginY

      public Divider setMarginY(int margin)
      Sets vertical margin (top and bottom) in pixels.
      Parameters:
      margin - the margin in pixels
      Returns:
      this Divider for method chaining
    • setMarginX

      public Divider setMarginX(String margin)
      Sets horizontal margin (left and right) for vertical dividers.
      Parameters:
      margin - the margin value (e.g., "1rem", "16px")
      Returns:
      this Divider for method chaining
    • setMarginX

      public Divider setMarginX(int margin)
      Sets horizontal margin (left and right) in pixels.
      Parameters:
      margin - the margin in pixels
      Returns:
      this Divider for method chaining