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 size | Window width |
|---|---|
XSmall | less than 600 px |
Small | 600 px to less than 960 px |
Medium | 960 px to less than 1280 px |
Large | 1280 px to less than 1920 px |
XLarge | 1920 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
Functions
Section titled “Functions”decideBySize()
Section titled “decideBySize()”decideBySize<T>(options: Partial<Record<ScreenSize, T>> | [T, T, T, T, T]): T;Returns the value that applies to the current screen size.
| Parameter | Type | Description |
|---|---|---|
options | Partial<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 XLargeconst columns = Sys.Layout.decideBySize({ XSmall: 1, Medium: 2, Large: 3 })Returns: T · Availability: Client
Properties
Section titled “Properties”screenSize
Section titled “screenSize”screenSize: (typeof ScreenSizes)[number];The current screen size: 'XSmall', 'Small', 'Medium', 'Large' or 'XLarge'.
Type: 'XSmall' \| 'Small' \| 'Medium' \| 'Large' \| 'XLarge' · Availability: Client
sizeEquals
Section titled “sizeEquals”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
Section titled “sizeIsGreaterThan”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
Section titled “sizeIsGreaterThanOrEqual”sizeIsGreaterThanOrEqual: BreakpointSection;Per screen size, whether the current screen size is that size or larger.
Type: BreakpointSection · Availability: Client
sizeIsLessThan
Section titled “sizeIsLessThan”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
Section titled “sizeIsLessThanOrEqual”sizeIsLessThanOrEqual: BreakpointSection;Per screen size, whether the current screen size is that size or smaller.
Type: BreakpointSection · Availability: Client
isHandset
Section titled “isHandset”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
Section titled “isTablet”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
Section titled “isHandsetPortrait”isHandsetPortrait: boolean;Whether isHandset is true and the window is in portrait orientation.
Type: boolean · Availability: Client
isTabletPortrait
Section titled “isTabletPortrait”isTabletPortrait: boolean;Whether isTablet is true and the window is in portrait orientation.
Type: boolean · Availability: Client
isWebPortrait
Section titled “isWebPortrait”isWebPortrait: boolean;Whether isWeb is true and the window is in portrait orientation.
Type: boolean · Availability: Client
isHandsetLandscape
Section titled “isHandsetLandscape”isHandsetLandscape: boolean;Whether isHandset is true and the window is in landscape orientation.
Type: boolean · Availability: Client
isTabletLandscape
Section titled “isTabletLandscape”isTabletLandscape: boolean;Whether isTablet is true and the window is in landscape orientation.
Type: boolean · Availability: Client
isWebLandscape
Section titled “isWebLandscape”isWebLandscape: boolean;Whether isWeb is true and the window is in landscape orientation.
Type: boolean · Availability: Client
isPortrait
Section titled “isPortrait”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
Section titled “isLandscape”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
Related
Section titled “Related”- Layout components
- Sys.Screen
- Sys API overview