Enum Class Breakpoint
- All Implemented Interfaces:
Serializable,Comparable<Breakpoint>,Constable
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:
| Breakpoint | Min Width | Target Devices |
|---|---|---|
| XS | 0px | Small phones |
| SM | 640px | Large phones, small tablets |
| MD | 768px | Tablets |
| LG | 1024px | Small laptops, tablets landscape |
| XL | 1280px | Desktops |
| XXL | 1536px | Large 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionLarge - 1024px and up (small laptops, tablets landscape).Medium - 768px and up (tablets).Small - 640px and up (large phones, small tablets).Extra large - 1280px and up (desktops).Extra small - 0px and up (default/mobile).2x Extra large - 1536px and up (large desktops). -
Method Summary
Modifier and TypeMethodDescriptionstatic BreakpointFinds a breakpoint by its name.Returns a CSS media query condition (without @media prefix).Returns a CSS media query condition for smaller screens (without @media prefix).Returns a CSS media query for screens smaller than this breakpoint (max-width).Returns a CSS media query for this breakpoint (min-width).intReturns the minimum width in pixels for this breakpoint.getName()Returns the short name of this breakpoint.next()Returns the next larger breakpoint.previous()Returns the previous smaller breakpoint.toString()static BreakpointReturns the enum constant of this class with the specified name.static Breakpoint[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
XS
Extra small - 0px and up (default/mobile). -
SM
Small - 640px and up (large phones, small tablets). -
MD
Medium - 768px and up (tablets). -
LG
Large - 1024px and up (small laptops, tablets landscape). -
XL
Extra large - 1280px and up (desktops). -
XXL
2x Extra large - 1536px and up (large desktops).
-
-
Method Details
-
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
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 nameNullPointerException- 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
Returns the short name of this breakpoint.- Returns:
- the breakpoint name (e.g., "sm", "md", "lg")
-
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
Returns a CSS media query condition (without @media prefix).- Returns:
- the media query condition
-
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
Returns a CSS media query condition for smaller screens (without @media prefix).- Returns:
- the max-width media query condition
-
fromName
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
Returns the next larger breakpoint.- Returns:
- the next breakpoint, or null if this is the largest
-
previous
Returns the previous smaller breakpoint.- Returns:
- the previous breakpoint, or null if this is the smallest
-
toString
- Overrides:
toStringin classEnum<Breakpoint>
-