Classes
Classes are sets of custom styles for elements or widgets. They are needed in order to simplify the process of styling the site.
You may change the design of identical elements by styling one and saving the setting in a class. After that, you may apply the saved class to other similar elements. You may apply any number of classes containing the desired styles to an element.
You may manage classes on the Design tab in the right panel of the Design Editor.
Each element has default styles. For example, the size or Auto Layout settings. Styles are assigned to an element automatically when it is added to the Canvas. These are unchangeable system styles. However, you may override the element's styles.
If you make changes to styles on the Design tab, they will be unique and applied only to the selected element. These are unique element styles.
If you want to add the same styles to several elements, create a class with the necessary settings.
An element may have no assigned classes, in which case the styles will be available on the Design tab. These are unique styles. To set such styles, you do not need to create a class, just select the desired settings on the Design tab.
This styling method is suitable if the element styles do not have to be reused. For example, this way you can add a font for the entire project by applying it to the Root layer.
Unique styles are highlighted by the color of the breakpoint for which they were added.
With custom classes you may save style settings to reuse them later. Once you've created a class for an element, you may customize the styles you want. Then, assign this class to other elements in the project that should have similar styles.
The custom class will be highlighted with the color of the breakpoint for which it was created.
You may assign several classes to an element, thereby defining sets of different styles. For example, you may create button-big and button-small classes with size and typographics for buttons, and button-success and button-info classes that define button functions. This way you may combine these classes, applying them to different buttons, to create the desired interface.
To add a custom class, click “+” in Classes.
By default, a class is created with the name class. You may change it. To do this, enter the desired name in the block that opens. For example, let's create the button-color class, which will be responsible for the color of the button.
Name the class using Latin letters. No numbers in the beginning of the name or spaces are allowed.
To save the class, press the Enter. The class appears in the element's class list. Now you may set styles for it.
When you create a class, it is added without any styles specified. You may add styles to that class. Let's add a background for the created button-color class.
To add the desired styles:
- Click “+” next to the desired property. Styles are added separately for each selected property;
- Set the desired properties. Add Background color.
Add style properties one by one.
Assigning the created class to elements
You may assign any class that has already been added to the project to an element. For example, set the background color for the blocklist. To do this, select an element on the Canvas and:
- click “+” in Classes;
- start entering the name of the desired background-color class — a list of project classes that match the one you are looking for will open below;
- click the desired class, it will be assigned to the element and displayed in the list of its classes. You will also see how many classes are assigned to the element.
The same class can be reused not only for identical elements, but also to set styles for different elements.
You may do the following with Custom Classes:
- Rename;
You may assign a name to the class that describes its purpose as accurately and clearly as possible. For example, the border-radius class will be responsible for rounding the corners of elements.
Use Latin letters to name the class. No numbers in the beginning of the name or spaces are allowed.
- Duplicate
You may create a copy of the class containing all the styles applied to it, and then change some of the styles to create modifications. For example, the newly created button-color-contact class can be responsible for the color of buttons that are needed to collect contact data from site visitors.
- Duplicate and replace
This way you may simultaneously copy the class and replace the class of the selected element.
- Delete from the element
This is used to delete styles from the selected element. Other elements with the same class will [reserve their settings.
- Delete from the project
If you remove a class from a project, all elements that were assigned that class will have their custom styles removed.
To use the previously created class:
- click Applied classes to open the list;
- hover over the desired class and click Edit;
- open the context menu next to the class name by clicking the three dots;
- select the desired action in the list.
To change the existing class styles, click Edit in the list of classes or class name in the style panel. The class styles editing menu will open.
Follow the instructions above to configure the desired style settings. This way, you may consistently define styles for all classes of an element, switching between them.
Changing the styles of the class that is assigned to multiple project elements automatically affects the styles of all of those elements. You may change the styles of the class assigned to any of the elements. These changes will automatically be applied to the remaining elements.
For example, you need to change the background color of the buttons that allow the user to leave a request on the site.
- Select one of the buttons on the Canvas, add a new class in Classes or select the already created button-color class.
- Assign the background color to the class, for example, green.
- Assign the resulting button-color class to other similar project elements.
Ready! The selected background will be applied to all the buttons that help the user leave a request on the site.
By changing one element, you will change all the necessary elements at once. This simplifies the process of website styling.
If you have assigned several classes to an element, the styles of all of these classes will be applied to it. If the same style parameter is specified in two or more classes, although with different values (for example, the background color is set to green in one class, and blue in the other), then the class that is closest to the beginning of the list will take precedence.
For example, the button has rounded corners and background color. The following classes are used: button-color-green (responsible for the green background color), button-color-blue (responsible for the blue background color) and button-border (responsible for the rounded corners).
Since the button-color classes are responsible for the same parameter, button-color-blue will have priority — it is closer to the beginning of the list. The background color of the button will be blue.
button-border is the only class responsible for the rounded corners, so these styles will be applied.
If an element has more than one class with the same styles, the priority one will be available in the styles panel.
You can see the rest by clicking the button with a number next to the class name.