Mixins in an override CSS

Mixins define a combination of reusable text, border, or background styles, enabling you to create incremental styling changes and provide a natural cascading of styles. Use mixins to ensure consistency across your user interface, maximize reuse, and minimize future maintenance. Mixins are defined on the Mixins tab of the skin and can be used throughout an application. You can reference one or multiple mixins to define the appearance of UI components such as buttons or links.

When you use a custom cascading style sheet (CSS) to override the skin, you can reference a mixin in the override CSS so that you can customize the presentation of specific elements while preserving the mixin styling for text, borders, and backgrounds. The benefit of preserving the mixin style is that you can change mixins in the skin at any time. A change to the mixin cascades throughout all elements in the skin that reference the mixin so that you can use the mixins that are defined in the skin in components that are not specifically supported in the skin.

Custom mixin variables that are defined in one override CSS are visible to all the override CSS files in your skin. To use the variable as reference, you must first define it. For best results, define all your custom variables in the top-level override CSS file.

The override CSS for your skin and all the override CSS files attached to the inherited skin are processed simultaneously and will use the values of the mixin that is currently defined in your skin. For example, a skin inherits from the pyEndUser skin, which includes the General typography mixin. If you have an override CSS file attached to the pyEndUser skin and you override the General mixin to change the color, then the override CSS file that is attached to pyEndUser will now use the new mixin value.

Mixin variable format

When referencing a mixin in custom CSS, the format of the mixin reference must follow a specific format. For example, if the mixin name is Header Background, the name of the mixin variable must start with $mx-header_background-xxxx. The format of the mixin variable is defined as:

$mx-<mixin name>-<attribute>

where

<mixin name> is the name of the mixin in all lowercase with spaces replaced by an underscore ( _ ) character.

<attribute> is a CSS attribute such as color, font-family, or background. The list of supported attributes is below.

If you want to override the standard button in the override CSS to use the mixin called "Test Border" for the border and the mixin "Error Text" for the color, you can use the following CSS override:

If the mixin variable does not exist, for example if it contains a typo, then it will be replaced by an empty value. To debug this kind of issue, enable the debug log on the CSSCustomParser class and look for an invalid variable definition in the log.

You cannot use mixin variables or refer to mixin settings inside CSS files that are attached to the harness. CSS files attached to the harness are not preprocessed and cannot use custom variables.

It is not possible to override the value of a mixin value such as $mx-general-color in your override CSS files. Because the value is already defined before processing the CSS, it will be replaced with the existing value.

Mixin attributes exposed

The following lists the attributes exposed for each mixin type.

Typography mixins

Typography mixins expose the following attributes:

font-family

color

font-weight

font-size

For example, using the "General" mixin, the following variables can be set before parsing any override CSS:

Border mixins

Border mixins expose the three border attributes (style, color, and width) and the shorthand version for all four border positions (left, right, top, bottom) as well as the global border. For example, the border mixin "Test border" exposes the following variables:

Combination mixins

Combination mixins have all three types listed above: typography, border, and background. Each of these attributes can be turned on or off.
The same type of variables will be generated for a combination mixin depending on which type is enabled.

Support for additional styles in mixins

Additional styles are supported for typography and background mixins. These styles are also exposed as custom variables. For example, you can create a general margin mixin and use the exposed variables through override CSS. If the mixin has the following additional styles, the color mixin inherits from the additional style.

Using custom variables

You can use custom variables directly in the override CSS. A variable must start with the dollar sign ($) character and must be defined before being referenced. For example, if your override CSS file contains the following lines:

In this scenario, the value that is assigned to a variable must be static and cannot contain a reference to another variable. For example, the following code indicates that the variable myvar is initialized with the string $mx-general-font-size. There is no evaluation of the value of the variable:

$myvar:$mx-general-font-size;

Viewing the content of the preprocessed CSS file

Use the skin preview to view the content after preprocessing. On the skin rule, click Actions > Preview.

CSS override files are encapsulated in a comment with the name of the CSS file. You can download the file and open it with a text editor. The skin preview only shows the override CSS content that is included in your skin and does not contain the override CSS from inherited skins.

Have a question? Get answers now.

About Pegasystems

Pegasystems is the leader in cloud software for customer engagement and operational excellence. If you’ve driven a car, used a credit card, called a company for service, opened an account, flown on a plane, submitted a claim, or performed countless other everyday tasks, chances are you’ve interacted with Pega. For the past 30 years, our technology – CRM, digital process automation, robotics, AI, and more – has empowered the world’s leading companies to achieve breakthrough results.