Skip to main content
Version: 4.64

Style

Styles define properties used to configure views based on the device type and current orientation. They allow you to specify layouts, colors and other view properties for different devices and orientations.

Quick guide​

Style files are JSON files stored in the ./style directory.

./style/
└── detailViewStyle.json

A style file can look like this:

{
"name": "detailViewStyle",
"content": {
"content": {
"portrait": {
"layoutName": {
"phone": "detailViewPortrait",
"tab7": "detailViewTabPortrait",
"tab12": "detailViewTabPortrait"
},
"backgroundColor": "#f3f3f3"
},
"landscape": {
"layoutName": {
"phone": "detailViewLandscape",
"tab7": "detailViewTabLandscape",
"tab12": "detailViewTabLandscape"
},
"backgroundColor": "#f3f3f3"
},
"orientation": {
"phone": "all",
"tab7": "all",
"tab12": "all"
}
}
}
}

In this example, the style defines different layouts for portrait and landscape orientations. The background color is set, and all orientations are allowed for each device type.

A style can also extend another style by specifying the parent field. The parent style provides the base configuration, which is merged with the current style.

Style files​

./style directory​

Style files are stored in the ./style directory. Each file defines a named style.

./style/
├── detailViewStyle.json
└── homeViewStyle.json

Style file structure​

Each style file is a JSON file containing a name field and a content object.

  • name: The name of the style. It must match the file name.
  • content: The style configuration.
    • parent (optional): The name of the parent style.
    • content: Contains the style properties.

The style properties can be defined for the default configuration, portrait orientation or landscape orientation.

  • default: Defines the default style values.
  • portrait: Defines style values for portrait orientation.
  • landscape: Defines style values for landscape orientation.
  • orientation: Defines the allowed orientations for each device type.

The default key can also be used to define fallback values instead of specifying individual device types or orientations.

Orientation​

The orientation field defines which orientations are allowed for each device type.

The following values are supported:

ValueDescription
allAll orientations are allowed.
portraitOnly portrait orientation is allowed.
landscapeOnly landscape orientation is allowed.
portraitSensorPortrait and reverse portrait orientations are allowed.
landscapeSensorLandscape and reverse landscape orientations are allowed.

Style Values​

The following table lists all available style values.

note

For legacy reasons, not all style values support device-specific configuration. For example, backgroundColor must be defined directly within the orientation configuration.

This is indicated by the Allows Device Type column in the table.

KeyTypeDescriptionDefault ValueAllows Device Type
layoutNameStringThe name of the layout to be used.nulltrue
menuWidthUnitSizeOpens the view as a side menu and defines its width.nulltrue
backgroundColorColorThe background color of the view.nulltrue
bottombarBackgroundColorColorThe background color of the bottom bar.nulltrue
loadingBackgroundColorColorThe background color displayed while the loading indicator is visible.nulltrue
loadingSpinnerColorColorThe color of the loading spinner.nulltrue
statusbarBackgroundColorColorThe background color of the status bar.nulltrue
navbarBackgroundColorColorThe background color of the navigation bar.nulltrue
navbarDisabledBooleanDefines whether the navigation bar is disabled.nulltrue
navbarElevationIntegerDefines the elevation of the navigation bar. A drop shadow is applied when a value is set.nulltrue
navbarHeightsUnitSizeThe height of the navigation bar.nulltrue
navbarLayoutStringThe name of the layout to be used for the navigation bar.nulltrue
tabbarBackgroundColorColorThe background color of the tab bar.nullfalse
tabbarBackgroundImageActiveStringThe URL of the image to be used as the active image if the view is part of a tab view.nullfalse
tabbarBackgroundImageInactiveStringThe URL of the image to be used as the inactive image if the view is part of a tab view.nullfalse
tabbarBackgroundImageActiveScaleTypeScaleTypeThe scale type of the active image if the view is part of a tab view.nullfalse
tabbarBackgroundImageInactiveScaleTypeScaleTypeThe scale type of the inactive image if the view is part of a tab view.nullfalse
tabbarHeightsUnitSizeThe height of the tab bar.nulltrue
tabbarLayoutStringThe name of the layout to be used for the tab bar.nulltrue

Usage​

A named style can be applied when creating a view using the showView action. Specify the style name using the namedStyle parameter.

{
"type": "showView",
"params": {
"layout": "detailView",
"staticTemplate": "detailView",
"namedStyle": "detailViewStyle"
}
}

In this example, the view uses the detailViewStyle style.

Troubleshooting​

If a style is not applied as expected, check the following:

  1. Is the style file stored in the ./style directory?
  2. Is the intended style referenced using the namedStyle parameter in the showView action?
  3. Is the correct layout defined for the current device type and orientation?
  4. If the style extends a parent style, are the inherited values and overrides configured correctly?