Enum Class Breakpoint

java.lang.Object
java.lang.Enum<Breakpoint>
com.oorian.html.layout.responsive.Breakpoint
All Implemented Interfaces:
Serializable, Comparable<Breakpoint>, Constable

public enum Breakpoint extends Enum<Breakpoint>
Standard responsive breakpoint definitions for mobile-first design.

Breakpoint defines the standard screen size thresholds used for responsive layouts. These values follow common conventions used by CSS frameworks like Tailwind and Bootstrap, enabling consistent responsive behavior across the application.

Breakpoint Values:

BreakpointMin WidthTarget Devices
XS0pxSmall phones
SM640pxLarge phones, small tablets
MD768pxTablets
LG1024pxSmall laptops, tablets landscape
XL1280pxDesktops
XXL1536pxLarge desktops

Usage:


 // Get breakpoint values
 int tabletWidth = Breakpoint.MD.getMinWidth();  // 768
 String mediaQuery = Breakpoint.LG.getMediaQuery();  // "@media (min-width: 1024px)"

 // Use with responsive components
 Show showOnDesktop = new Show(Breakpoint.LG);
 Hide hideOnMobile = new Hide(Breakpoint.SM);

 // Build responsive values
 ResponsiveValue<Integer> columns = ResponsiveValue.of(1).sm(2).lg(4);
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Enum Constant Details

    • XS

      public static final Breakpoint XS
      Extra small - 0px and up (default/mobile).
    • SM

      public static final Breakpoint SM
      Small - 640px and up (large phones, small tablets).
    • MD

      public static final Breakpoint MD
      Medium - 768px and up (tablets).
    • LG

      public static final Breakpoint LG
      Large - 1024px and up (small laptops, tablets landscape).
    • XL

      public static final Breakpoint XL
      Extra large - 1280px and up (desktops).
    • XXL

      public static final Breakpoint XXL
      2x Extra large - 1536px and up (large desktops).
  • Method Details

    • values

      public static Breakpoint[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Breakpoint valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getMinWidth

      public int getMinWidth()
      Returns the minimum width in pixels for this breakpoint.
      Returns:
      the minimum width in pixels
    • getName

      public String getName()
      Returns the short name of this breakpoint.
      Returns:
      the breakpoint name (e.g., "sm", "md", "lg")
    • getMediaQuery

      public String getMediaQuery()
      Returns a CSS media query for this breakpoint (min-width).

      Uses mobile-first approach with min-width queries.

      Returns:
      the CSS media query string
    • getCondition

      public String getCondition()
      Returns a CSS media query condition (without @media prefix).
      Returns:
      the media query condition
    • getMaxWidthMediaQuery

      public String getMaxWidthMediaQuery()
      Returns a CSS media query for screens smaller than this breakpoint (max-width).

      Uses max-width query, which is useful for targeting smaller screens.

      Returns:
      the CSS media query string for smaller screens
    • getMaxWidthCondition

      public String getMaxWidthCondition()
      Returns a CSS media query condition for smaller screens (without @media prefix).
      Returns:
      the max-width media query condition
    • fromName

      public static Breakpoint fromName(String name)
      Finds a breakpoint by its name.
      Parameters:
      name - the breakpoint name (e.g., "sm", "md", "lg")
      Returns:
      the matching Breakpoint, or null if not found
    • next

      public Breakpoint next()
      Returns the next larger breakpoint.
      Returns:
      the next breakpoint, or null if this is the largest
    • previous

      public Breakpoint previous()
      Returns the previous smaller breakpoint.
      Returns:
      the previous breakpoint, or null if this is the smallest
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Breakpoint>