Architecture
The design system is a Mantine theme with a small set of components built on top of it. This page describes the layers it is made of, how the package is organised and the principles that apply across it.
Theme layers
Every component on this site is the result of up to five layers. Knowing which layer a change belongs to tells you where to make it.
| Layer | Responsibility |
|---|---|
| 1. Mantine | Markup, keyboard behaviour, accessibility and the Styles API. Used as published, without modification. |
| 2. Theme | Default props and stylesheets per component, and the global scales: colour, spacing, radius, type, shadow |
| 3. Semantic tokens | Named roles such as surface and button colour, mapped to a palette shade per colour scheme |
| 4. Style overrides | Pseudo-classes, states, nested parts and dark-mode rules the Styles API cannot express |
| 5. Custom components | Components built here when the four layers above are not enough |
The theme also maps the design system's variant names onto Mantine's own, so that
variant="primary" resolves to Mantine's filled variant.
Semantic tokens name a role, not a colour. Each token can point to a different shade in light and dark mode, so a component that uses it is correct in both.
Package structure
packages/mc-design-system/
├── src/
│ ├── index.ts public API
│ ├── styles.css global styles, published as /styles.css
│ ├── components/ custom components, one folder each
│ │ └── Chip/
│ │ ├── Chip.tsx
│ │ └── Chip.module.css
│ └── themes/
│ ├── theme.ts the theme: global scales and the assembled registrations
│ ├── component-overrides/ component registrations, one file per family
│ ├── base-colors.ts the nine palettes
│ ├── cssVariablesResolver.ts semantic tokens per colour scheme
│ └── style-overrides/ one stylesheet per Mantine component
│ └── button.module.css
└── tools/ authoring utilities, not published
└── apca.ts
The file name shows which kind of stylesheet you are looking at. A PascalCase stylesheet belongs to the custom component next to it. A kebab-case stylesheet in style-overrides restyles a stock Mantine component everywhere it is used.
Principles
The public API is what the package root exports. Everything else is internal and can change in any release.
The package is ESM only. There is no CommonJS build.
Peer dependencies are never bundled. React, the Mantine packages and the Tiptap packages are peer dependencies, so the application owns a single copy of each.
The theme and the components ship together in one package.
A theme stylesheet applies to one component. Mantine attaches a stylesheet registered in the theme to the component it is registered on. Most components that render another component internally do not pass that stylesheet on:
| Base | Resolves under | Reaches every consumer |
|---|---|---|
Input | ["Input", __staticSelector] | Yes |
Input.Wrapper | ["InputWrapper", __staticSelector] | Yes |
Popover | __staticSelector | No |
Combobox | __staticSelector || "Combobox" | No |
The input stylesheet therefore reaches TextInput, Select and the date inputs at once. The popover stylesheet reaches Popover and nothing else, because Menu, Select and the other floating components register their panels under their own names. The theme applies the shared panel style to each of them individually, and a new floating component must be added to that list.
Default props are not affected. They are read by the inner component and do cascade.
Colour schemes
Light and dark mode are both fully supported, and neither is derived from the other. The accent colour is one step lighter in dark mode, and several semantic tokens point to different shades rather than inverting. A visual change must be checked in both schemes.
On this site, the colour scheme toggle in the navigation bar controls both the site and the component examples.
Contrast
Contrast is measured with APCA instead of the WCAG 2.x contrast ratio. This replaces success criteria 1.4.3 and 1.4.11. The rest of WCAG 2.1 AA applies unchanged.
Related
- Accessibility — contrast thresholds and shared focus, disabled and labelling behaviour
- Building a custom component — choosing the tier and building layer 5
- Versioning — what each release number means