Class Breakpoints<V>

java.lang.Object
org.patternfly.core.Tuples<Breakpoint,V>
org.patternfly.style.Breakpoints<V>
Type Parameters:
V - the type of values associated with each breakpoint
All Implemented Interfaces:
Iterable<Tuple<Breakpoint,V>>

public class Breakpoints<V> extends Tuples<Breakpoint,V>
This class represents a collection of breakpoints and associated values. It extends the Tuples class and adds methods to generate CSS modifier classes. The class is used as parameter in various components and layouts to apply CSS modifiers for responsive layout.

The CSS modifier class for a single breakpoint is generated using the following rules:

  • For normal breakpoints (modifiers() methods)
    • default breakpoint: pf-m-<value>
    • all other breakpoints: pf-m-<value>-on-<breakpoint>
  • For vertical breakpoints (verticalModifiers() methods)
    • default breakpoint: pf-m-<value>
    • all other breakpoints: pf-m-<value>-on-<breakpoint>-height

When generating the CSS modifier classes, String.valueOf(Object) is used by default to build the <value> part. If the value type implements TypedModifier, TypedModifier.value() is used instead.

Breakpoints can be created using either factory methods or a fluent API:

breakpoints(
        default_, 1,
        sm, 2,
        lg, 3);
breakpoints()
        .default_(1)
        .sm(2)
        .lg(3);

To get the CSS modifiers classes, use the modifiers() and verticalModifiers() methods. Depending on the signature they return a list of CSS modifier classes, a single CSS modifier class or an empty string.

// pf-m-foo pf-m-bar-on-lg
breakpoints(default_, "foo", lg, "bar").modifiers();

// pf-m-start-foo__end-on-sm pf-m-start-bar__end-on-lg
breakpoints(sm, "foo", lg, "bar").modifiers(v -> "start-" + v + "__end");

// pf-m-a pf-m-b-on-sm-height pf-m-c-on-md-height pf-m-d-on-lg-height pf-m-e-on-xl-height pf-m-f-on-2xl-height
breakpoints(
        default_, "a",
        sm, "b",
        md, "c",
        lg, "d",
        xl, "e",
        _2xl, "f")
        .verticalModifiers();

breakpoints(md, "foo", lg, "bar").modifiers(md); // pf-m-foo, because md in [md, lg]
breakpoints(md, "foo", lg, "bar").modifiers(_2xl); // pf-m-foo, because [md, lg] < _2xl
breakpoints(md, "foo", lg, "bar").modifiers(sm); // "", because [md, lg] > sm

  • Method Details

    • breakpoints

      public static <V> Breakpoints<V> breakpoints()
      Creates a new instance of Breakpoints with an empty list of breakpoints.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint, V value)
      Creates a new instance of Breakpoints with a single tuple containing the given breakpoint and value.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint1, V value1, Breakpoint breakpoint2, V value2)
      Creates a new instance of Breakpoints with two tuples containing the given breakpoints and values.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint1, V value1, Breakpoint breakpoint2, V value2, Breakpoint breakpoint3, V value3)
      Creates a new instance of Breakpoints with three tuples containing the given breakpoints and values.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint1, V value1, Breakpoint breakpoint2, V value2, Breakpoint breakpoint3, V value3, Breakpoint breakpoint4, V value4)
      Creates a new instance of Breakpoints with four tuples containing the given breakpoints and values.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint1, V value1, Breakpoint breakpoint2, V value2, Breakpoint breakpoint3, V value3, Breakpoint breakpoint4, V value4, Breakpoint breakpoint5, V value5)
      Creates a new instance of Breakpoints with five tuples containing the given breakpoints and values.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Breakpoint breakpoint1, V value1, Breakpoint breakpoint2, V value2, Breakpoint breakpoint3, V value3, Breakpoint breakpoint4, V value4, Breakpoint breakpoint5, V value5, Breakpoint breakpoint6, V value6)
      Creates a new instance of Breakpoints with six tuples containing the given breakpoints and values.
    • breakpoints

      public static <V> Breakpoints<V> breakpoints(Iterable<Tuple<Breakpoint,V>> breakpoints)
      Creates a new instance of Breakpoints with the given breakpoints and values.
    • default_

      public Breakpoints<V> default_(V value)
      Adds the given value for the default breakpoint to the list of breakpoints.
    • sm

      public Breakpoints<V> sm(V value)
      Adds the given value for the small breakpoint to the list of breakpoints.
    • md

      public Breakpoints<V> md(V value)
      Adds the given value for the medium breakpoint to the list of breakpoints.
    • lg

      public Breakpoints<V> lg(V value)
      Adds the given value for the large breakpoint to the list of breakpoints.
    • xl

      public Breakpoints<V> xl(V value)
      Adds the given value for the x-large breakpoint to the list of breakpoints.
    • _2xl

      public Breakpoints<V> _2xl(V value)
      Adds the given value for the 2xl breakpoint to the list of breakpoints.
    • modifiers

      public String modifiers()
      Returns the CSS modifiers classes for the breakpoints of this class as a string separated by " ".

      When generating the CSS modifier classes, String.valueOf(Object) is used by default to build the <value> part. If the value type implements TypedModifier, TypedModifier.value() is used instead.

    • modifiers

      public String modifiers(Function<V,String> stringValue)
      Returns the CSS modifiers classes for the breakpoints of this class as a string separated by " ".

      When generating the CSS modifier classes, the specified function is used to build the <value> part.

    • modifiers

      public String modifiers(Breakpoint breakpoint)
      Returns a single CSS modifier class for the given breakpoint, if this class contains the breakpoint. Otherwise, returns a single CSS modifier class for the given breakpoint, if this class contains a breakpoint smaller than the given one. Otherwise, this method returns an empty string.

      This method does not add the -on-<breakpoint> suffix!

      When generating the CSS modifier classes, String.valueOf(Object) is used by default to build the <value> part. If the value type implements TypedModifier, TypedModifier.value() is used instead.

    • modifiers

      public String modifiers(Breakpoint breakpoint, Function<V,String> stringValue)
      Returns a single CSS modifier class for the given breakpoint, if this class contains the breakpoint. Otherwise, returns a single CSS modifier class for the given breakpoint, if this class contains a breakpoint smaller than the given one. Otherwise, this method returns an empty string.

      This method does not add the -on-<breakpoint> suffix!

      When generating the CSS modifier classes, the specified function is used to build the <value> part.

    • verticalModifiers

      public String verticalModifiers()
      Returns the vertical CSS modifiers classes for the breakpoints of this class as a string separated by " ".

      When generating the CSS modifier classes, String.valueOf(Object) is used by default to build the <value> part. If the value type implements TypedModifier, TypedModifier.value() is used instead.

    • verticalModifiers

      public String verticalModifiers(Function<V,String> stringValue)
      Returns the vertical CSS modifiers classes for the breakpoints of this class as a string separated by " ".

      When generating the CSS modifier classes, the specified function is used to build the <value> part.