Implement Native Styling

Last update: Download PDF Edit

1 Introduction

With Mendix 8, you can build native apps with custom styling in Mendix Studio Pro. Styling native mobile apps uses JavaScript style sheets, which are new to Mendix Studio Pro. Consult the guidelines below for information on theme folder structure, classes, and design properties.

2 Theme Folder Structure

For each app project, styling is stored in the theme/styles folder. From there styling is split into native and web folders. Both have the same structure.

These folders have strict protocols:

  • Users should only add or change styling in the app folder
  • The app folder has two files: custom.js and custom-variables.js – when changing the styling, always copy the variable you want to change from native/core/variables.js to native/app/custom-variables.js
  • The custom-variables.js file will overwrite the variables.js file – do not change anything in the core folder directly, as this makes updating Atlas more difficult
  • Any variables you want to change or add should be put in custom-variables.js
  • Any classes you want to change or add should be put in custom.js

The native/core/_helperfunctions folder contains multiple helper functions. These functions can help you style more easily. For example, the adjustFont function receives a font and adjusts it to the screen size. This will make your font sizes responsive. For more information about these helper classes, see their descriptions in the code.

The native/core/base folder contains helpers.js, which includes all helper classes. These classes are generic and can be put on all widgets. Some of them are also available as design properties in Mendix Studio Pro.

The native/core/widgets folder contains widget styling. Every widget has its own file which contains its default class names. Some widgets also have specific design properties. One exception to these guidelines is typography.js, which contains all typography-related classes.

In native/resources you will find resource package styling. Here you can find all styling related to building blocks and page templates.

3 Classes

Default class names – which are the class names set by Mendix Studio Pro – will always be named in Pascal case. All other classes will be in camel case. This keeps changes to default widget styles clear.

4 Design Properties

Available in Mendix Studio and Mendix Studio Pro, design properties are an easier way to apply classes. Atlas already offers several useful design properties out of the box. You can see them by clicking on a widget and looking at the Properties panel. A design property can be either a drop-down menu or a toggle. A toggle will toggle one class, while a drop-down menu will apply a different class for each drop-down item.

5 Read More