Design tokens, CSS classes, mixins and CSS parts - when to use each
The Maersk Design System offers a wide range of options when it comes to styling your application.
In your code, you can use our Foundations CSS classes, design tokens (CSS properties) and Sass mixins and CSS parts.
Each of these options has its own use-case and benefits. In this article, I will explain when to use each of them and how to use them in your code.
Styling your application
The recommended rules are:
- Use our Foundations CSS classes for basic styling of your application, for adding proper font style, or background color, border color, etc. to some elements in your application (see the full list of available CSS classes).
- Use CSS properties and design tokens for adding specific theme colors, spacing, border radiuses, etc. inside your applications stylesheet (see the full list of available design tokens and CSS properties).
- Use Sass mixins to apply breakpoints or typography in your code (see the full list of available Sass mixins).
Why should I use the MDS styling tools?
Using the MDS styling tools in your application:
- Ensures consistency - the tools MDS provides enforce an uniform design language across all platforms and applications.
- Follows MDS guidelines - your product will be consistent with the Maersk brand.
- Makes your code more maintainable and scalable.
- Makes your application more accessible and responsive.
- Takes advantage of the MDS theming system.
Foundations CSS classes
Adding an import to Foundations CSS in your application is the easiest way to use MDS styles in your code.
All you need to do is choose an MDS theme, include Foundations CSS in your code and add mds class to the root element of HTML. By doing that, you will get default styling for main elements in your application, like headings, paragraphs, lists, etc.
