Skip to content

Sys.Layout

Sys.Layout tells client-side code how large the End user’s browser window is and how it is oriented, so Screens can adapt to phones, tablets and desktops. All its properties are read-only and always reflect the current window: when the window is resized or rotated, Lowgile updates them and refreshes the app.

Window widths are grouped into five screen sizes, in this order:

Screen sizeWindow width
XSmallless than 600 px
Small600 px to less than 960 px
Medium960 px to less than 1280 px
Large1280 px to less than 1920 px
XLarge1920 px or more

Lowgile also adds the current screen size as a CSS class (for example Medium) to the page’s body element, so stylesheets can use it.

Availability: Client

decideBySize<T>(options: Partial<Record<ScreenSize, T>> | [T, T, T, T, T]): T;

Returns the value that applies to the current screen size.

ParameterTypeDescription
optionsPartial<Record<ScreenSize, T>> | [T, T, T, T, T]Either an object with a value per screen size, or an array with one value per screen size from XSmall to XLarge.

With an object, sizes can be left out: the value of the largest listed size that is not larger than the current size applies. If no listed size is small enough, the result is undefined. With an array, the value at the current size’s position applies; if the array is shorter, its last value applies.

// 1 column on XSmall and Small, 2 on Medium, 3 on Large and XLarge
const columns = Sys.Layout.decideBySize({ XSmall: 1, Medium: 2, Large: 3 })

Returns: T · Availability: Client

screenSize: (typeof ScreenSizes)[number];

The current screen size: 'XSmall', 'Small', 'Medium', 'Large' or 'XLarge'.

Type: 'XSmall' \| 'Small' \| 'Medium' \| 'Large' \| 'XLarge' · Availability: Client

sizeEquals: BreakpointSection;

Per screen size, whether it is the current screen size. BreakpointSection is Record<ScreenSize, boolean>, so you read it as, for example, Sys.Layout.sizeEquals.Small.

Type: BreakpointSection · Availability: Client

sizeIsGreaterThan: BreakpointSection;

Per screen size, whether the current screen size is larger than it. For example, Sys.Layout.sizeIsGreaterThan.Small is true on Medium, Large and XLarge.

Type: BreakpointSection · Availability: Client

sizeIsGreaterThanOrEqual: BreakpointSection;

Per screen size, whether the current screen size is that size or larger.

Type: BreakpointSection · Availability: Client

sizeIsLessThan: BreakpointSection;

Per screen size, whether the current screen size is smaller than it. For example, Sys.Layout.sizeIsLessThan.Medium is true on XSmall and Small.

Type: BreakpointSection · Availability: Client

sizeIsLessThanOrEqual: BreakpointSection;

Per screen size, whether the current screen size is that size or smaller.

Type: BreakpointSection · Availability: Client

isHandset: boolean;

Whether the window has phone dimensions: narrower than 600 px in portrait, or narrower than 960 px in landscape orientation.

Type: boolean · Availability: Client

isTablet: boolean;

Whether the window has tablet dimensions: 600 px to less than 840 px wide in portrait, or 960 px to less than 1280 px wide in landscape orientation.

Type: boolean · Availability: Client

isWeb: boolean;

Whether the window has desktop dimensions: at least 840 px wide in portrait, or at least 1280 px wide in landscape orientation.

Type: boolean · Availability: Client

isHandsetPortrait: boolean;

Whether isHandset is true and the window is in portrait orientation.

Type: boolean · Availability: Client

isTabletPortrait: boolean;

Whether isTablet is true and the window is in portrait orientation.

Type: boolean · Availability: Client

isWebPortrait: boolean;

Whether isWeb is true and the window is in portrait orientation.

Type: boolean · Availability: Client

isHandsetLandscape: boolean;

Whether isHandset is true and the window is in landscape orientation.

Type: boolean · Availability: Client

isTabletLandscape: boolean;

Whether isTablet is true and the window is in landscape orientation.

Type: boolean · Availability: Client

isWebLandscape: boolean;

Whether isWeb is true and the window is in landscape orientation.

Type: boolean · Availability: Client

isPortrait: boolean;

Whether the window is in portrait orientation, that is, at least as tall as it is wide. Exactly one of isHandsetPortrait, isTabletPortrait and isWebPortrait is then true.

Type: boolean · Availability: Client

isLandscape: boolean;

Whether the window is in landscape orientation, that is, wider than it is tall. Exactly one of isHandsetLandscape, isTabletLandscape and isWebLandscape is then true.

Type: boolean · Availability: Client