Class Show


public class Show extends StyledElement<Show>
A container that shows its content only at specified breakpoints.

Show uses CSS media queries to conditionally display content based on screen size. Content is hidden by default and shown when the screen width matches the specified breakpoint conditions.

Visibility Modes:

Usage:


 // Show only on large screens and up (desktop)
 Show desktopOnly = Show.from(Breakpoint.LG);
 desktopOnly.addElement(desktopNavigation);

 // Show only on mobile (below SM breakpoint)
 Show mobileOnly = Show.below(Breakpoint.SM);
 mobileOnly.addElement(mobileMenu);

 // Show only on tablets (MD to LG)
 Show tabletOnly = Show.between(Breakpoint.MD, Breakpoint.LG);
 tabletOnly.addElement(tabletLayout);

 // Wrap existing element
 Show wrapper = Show.from(Breakpoint.MD, existingElement);
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Method Details

    • from

      public static Show from(Breakpoint breakpoint)
      Creates a Show container that displays content at the specified breakpoint and larger.

      Uses min-width media query (mobile-first approach).

      Parameters:
      breakpoint - the minimum breakpoint at which content is shown
      Returns:
      a new Show container
    • from

      public static Show from(Breakpoint breakpoint, Element<?> content)
      Creates a Show container with content, displayed at the specified breakpoint and larger.
      Parameters:
      breakpoint - the minimum breakpoint at which content is shown
      content - the element to show
      Returns:
      a new Show container
    • below

      public static Show below(Breakpoint breakpoint)
      Creates a Show container that displays content below the specified breakpoint.

      Uses max-width media query to show content on smaller screens.

      Parameters:
      breakpoint - content is shown below this breakpoint
      Returns:
      a new Show container
    • below

      public static Show below(Breakpoint breakpoint, Element<?> content)
      Creates a Show container with content, displayed below the specified breakpoint.
      Parameters:
      breakpoint - content is shown below this breakpoint
      content - the element to show
      Returns:
      a new Show container
    • only

      public static Show only(Breakpoint breakpoint)
      Creates a Show container that displays content only at the specified breakpoint range.

      Content is shown between this breakpoint's min-width and the next breakpoint's min-width (exclusive).

      Parameters:
      breakpoint - the exact breakpoint range to show content
      Returns:
      a new Show container
    • only

      public static Show only(Breakpoint breakpoint, Element<?> content)
      Creates a Show container with content, displayed only at the specified breakpoint range.
      Parameters:
      breakpoint - the exact breakpoint range to show content
      content - the element to show
      Returns:
      a new Show container
    • between

      public static Show between(Breakpoint from, Breakpoint to)
      Creates a Show container that displays content between two breakpoints (inclusive).
      Parameters:
      from - the minimum breakpoint (inclusive)
      to - the maximum breakpoint (inclusive)
      Returns:
      a new Show container
    • between

      public static Show between(Breakpoint from, Breakpoint to, Element<?> content)
      Creates a Show container with content, displayed between two breakpoints.
      Parameters:
      from - the minimum breakpoint (inclusive)
      to - the maximum breakpoint (inclusive)
      content - the element to show
      Returns:
      a new Show container
    • initialize

      protected void initialize()
      Called during initialization to add the responsive CSS to the page.
      Overrides:
      initialize in class StyledElement<Show>