Class PageSection


public class PageSection extends StyledElement<PageSection>
A page section element with configurable vertical spacing.

PageSection renders as an HTML <section> element and provides convenient methods for applying consistent vertical padding/margin. It's useful for dividing page content into logical groups with proper spacing.

Features:

  • Semantic <section> HTML element
  • Predefined spacing sizes
  • Vertical padding and margin helpers
  • Full-width background support

Usage:


 // Section with default spacing
 PageSection hero = new PageSection(PageSection.Spacing.LG);
 hero.addElement(new H1("Welcome"));
 hero.addElement(new Paragraph("Introduction text..."));

 // Section with background
 PageSection features = new PageSection(PageSection.Spacing.XL);
 features.setBackgroundColor("#f5f5f5");
 features.addElement(featureGrid);

 // Custom padding
 PageSection custom = new PageSection();
 custom.setPaddingY("4rem");
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • PageSection

      public PageSection()
      Constructs a page section with no initial spacing.
    • PageSection

      public PageSection(PageSection.Spacing spacing)
      Constructs a page section with the specified vertical padding.
      Parameters:
      spacing - the spacing preset for vertical padding
  • Method Details

    • setPaddingY

      public PageSection setPaddingY(PageSection.Spacing spacing)
      Sets vertical padding (top and bottom) using a spacing preset.
      Parameters:
      spacing - the spacing preset
      Returns:
      this PageSection for method chaining
    • setPaddingY

      public PageSection setPaddingY(String padding)
      Sets vertical padding (top and bottom) using a CSS value.
      Parameters:
      padding - the padding value (e.g., "2rem", "32px")
      Returns:
      this PageSection for method chaining
    • setPaddingY

      public PageSection setPaddingY(int padding)
      Sets vertical padding (top and bottom) in pixels.
      Parameters:
      padding - the padding in pixels
      Returns:
      this PageSection for method chaining
    • setPaddingX

      public PageSection setPaddingX(String padding)
      Sets horizontal padding (left and right) using a CSS value.
      Parameters:
      padding - the padding value (e.g., "1rem", "16px")
      Returns:
      this PageSection for method chaining
    • setPaddingX

      public PageSection setPaddingX(int padding)
      Sets horizontal padding (left and right) in pixels.
      Parameters:
      padding - the padding in pixels
      Returns:
      this PageSection for method chaining
    • setMarginY

      public PageSection setMarginY(PageSection.Spacing spacing)
      Sets vertical margin (top and bottom) using a spacing preset.
      Parameters:
      spacing - the spacing preset
      Returns:
      this PageSection for method chaining
    • setMarginY

      public PageSection setMarginY(String margin)
      Sets vertical margin (top and bottom) using a CSS value.
      Parameters:
      margin - the margin value (e.g., "2rem", "32px")
      Returns:
      this PageSection for method chaining
    • setMarginY

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