Design system - a single source of truth
Problem
Designs never really turn out the exact same after development. When I first joined Cubiko, there was no clear design system in place. With different analysts and engineers all working from the same codebase, we needed a way to ensure consistency and to also let the devs handle small design decisions without needing help from a designer.
Solution
After going through a few options, we settled on implementing a design token system in the form of SCSS file. It was set up to integrate into our codebase but still required a bit of manual work and CSS knowledge to get it working nicely. This supported the reusable components library that I had already set up in Figma.
Other options we explored:
- Using Figma as the source of truth and exporting to code;
- Using a token-specific configuration file;
- Using an external service to manage tokens.
All of the above had their own little annoyances and problems that made it more difficult to adopt and would affect the work process for devs.
How did it work?
Setting up the design tokens was a hurdle in itself. There was no consistency in terms of colours or spacing etc. I started by defining the primitive tokens, e.g. colours, shadows, font sizes, font weight, border radius and spacing. I also followed a 4pt grid system to ensure precision and consistency in implementation.
Colours were the most time-consuming as I took the opportunity to create a completely new set of colours that were more vibrant to fit the vibe and branding of Cubiko. I then picked a lighter shade and a medium to create a total of three variations. The rest of the tokens were configured to match what had already been implemented into the app and were also reflected in the component library in Figma.
Having a smaller, curated set of tokens meant that engineers and analysts could select from a pre-defined list which took the guess work out of small design decisions. This is also meant that designs were more likely to look harmonious and did not require extra design effort to check styling.
/** Example tokens.scss file **/
/* ****************
* Primitive tokens
* **************** */
:root {
/* Colours */
--red-20: #fef2f2;
--red-50: #ffc9c9;
--red-90: #fb2c36;
...
/* Shadows */
--shadow-20: 1px 2px 5px rgb(0 0 0 / 15%);
--shadow-50: 2px 5px 15px rgb(0 0 0 / 13%);
--shadow-70: 4px 7px 20px rgb(0 0 0 / 18%);
/* Font sizes */
--font-size-10: 0.625rem;
--font-size-20: 0.75rem;
--font-size-30: 0.875rem;
--font-size-40: 1rem;
...
/* Font weight */
--font-weight-light: 300;
--font-weight-regular: 400;
--font-weight-medium: 500;
...
/* Spacing */
--spacing-base: 4px;
--spacing-1: calc(1 * var(--spacing-base));
--spacing-2: calc(2 * var(--spacing-base));
--spacing-3: calc(3 * var(--spacing-base));
--spacing-4: calc(4 * var(--spacing-base));
...
/* Border radius */
--border-radius-sm: 4px;
--border-radius-md: 8px;
--border-radius-lg: 16px;
...
}
Example tokens.scss file
Example colours