Architecture
The token system is organized into several layers:Token Files
tokens.less
The main entry point that imports all token files:
tokens-citizen.less
Defines Citizen-specific design tokens including:
- Layout and spacing scale
- Citizen font families
- Header positioning system
- Size variables
- Transition timings
- Transform effects
- Border and shadow tokens
- Applies
.theme-base()mixin to:root - Responsive token adjustments via media queries
- Accessibility adaptations (contrast preferences)
- Animation tokens (applied when
.citizen-animations-ready)
tokens-theme-base.less
Defines the base theme color system using the .theme-base() mixin:
- OKLCH color space for perceptually uniform colors
- HSL fallbacks for browser compatibility
- Progressive color system
- Surface color scales (0-4)
- Text color hierarchy
- State colors (destructive, success, warning)
- Syntax highlighting colors
tokens-theme-dark.less
Defines dark theme overrides using the .theme-dark() mixin:
- Inverted lightness values
- Adjusted surface progression (lighter instead of darker)
- Higher contrast syntax colors
- Modified opacity and shadow values
- Inverted filter effects
tokens-codex.less
Overrides Codex Design Tokens to integrate with Citizen’s color system:
- Maps Codex semantic tokens to Citizen color primitives
- Backports Codex 2.0 typography tokens for MediaWiki 1.43 compatibility
- Provides multiple font size modes (small, medium, large, x-large)
variables.less
LESS variables for backwards compatibility and when LESS-specific features are needed:
- Need LESS mixins or functions
- Working with MediaWiki skin variables
- Extension compatibility
Color System
OKLCH Color Space
Citizen uses OKLCH for perceptually uniform colors:- L (Lightness): 0-100%, perceptually uniform
- C (Chroma): 0-0.4, color intensity
- H (Hue): 0-360, color angle
- Consistent perceived brightness across hues
- More vibrant colors than sRGB
- Better for programmatic color manipulation
- Modern browsers: OKLCH native support
- Fallback: HSL (automatically applied via
@supports)
Progressive Color
The primary accent color that influences the entire color system:- Links and interactive elements
- Primary buttons
- Surface tinting (subtle accent on backgrounds)
- Focus indicators
Surface Colors
A scale of background colors with progressive tinting:| Level | Usage | Light L | Dark L |
|---|---|---|---|
| Surface 0 | Page background | 96% | 14% |
| Surface 1 | Cards, panels | 94% | 16% |
| Surface 2 | Interactive elements | 92% | 18% |
| Surface 3 | Disabled backgrounds | 90% | 20% |
| Surface 4 | Elevated surfaces | 88% | 22% |
- Base color
- Hover state (+4% lightness shift)
- Active state (-4% lightness shift)
Text Colors
Hierarchical text colors with progressive hue influence:| Token | Light L | Dark L | Usage |
|---|---|---|---|
--color-emphasized | 5% | 93% | Headings, emphasis |
--color-base | 20% | 80% | Body text |
--color-subtle | 35% | 70% | Secondary text |
--color-placeholder | 40% | 60% | Placeholders |
--color-disabled | 60% | 50% | Disabled text |
Responsive Tokens
Some tokens automatically adjust at different breakpoints:--padding-page: 16px → 24px → 32px--header-card-maxheight: 80vh → calc(100vh - spacing)- Header position variables (changes based on configuration)
Accessibility Features
Contrast Preferences
Reduced Motion
Transitions are only applied when animations are ready:Color Scheme
Breakpoints
Citizen uses MediaWiki’s standard breakpoint system:| Breakpoint | Min Width | Max Width | Usage |
|---|---|---|---|
| Mobile | — | 719.98px | Single column, bottom nav |
| Tablet | 720px | 999.98px | Two columns, responsive nav |
| Desktop | 1000px | 1279.98px | Full layout, side navigation |
| Desktop Wide | 1280px | — | Extended content width |
Typography Scale
Citizen provides multiple typography modes via Codex mixins:Medium Mode (Default)
| Size | Font Size | Line Height | Usage |
|---|---|---|---|
| xxx-large | 1.75rem (28px) | 2.375rem (38px) | H1 |
| xx-large | 1.5rem (24px) | 2.125rem (34px) | H2 |
| x-large | 1.25rem (20px) | 1.875rem (30px) | H3 |
| large | 1.125rem (18px) | 1.75rem (28px) | H4 |
| medium | 1rem (16px) | 1.625rem (26px) | Body |
| small | 0.875rem (14px) | 1.375rem (22px) | Small text |
| x-small | 0.75rem (12px) | 1.25rem (20px) | Fine print |
.cdx-mode-small()- Compact interfaces.cdx-mode-large()- Better readability.cdx-mode-x-large()- Accessibility focus
Theme Switching
Citizen supports three theme modes:- Auto (OS) - Follows system preference
- Light - Force light theme
- Dark - Force dark theme
Customizing Tokens
Wiki-wide Customization
Add custom CSS toMediaWiki:Common.css:
Per-page Customization
Extension Integration
Extensions can use Citizen tokens for consistent styling:Token Reference
For complete token listings, see:- CSS Variables - All available CSS custom properties
- LESS Mixins - Reusable styling utilities
Best Practices
✅ Do
- Use CSS custom properties for runtime values
- Leverage semantic tokens (
--color-base,--background-color-interactive) - Use spacing scale for consistent spacing
- Respect theme switching
- Test in both light and dark themes
❌ Don’t
- Hardcode colors or spacing values
- Override tokens without considering theme switching
- Use LESS variables when CSS custom properties are available
- Create custom color scales (use surface/text hierarchies)
- Ignore responsive behavior of tokens
Related Resources
- Codex Design Tokens - Upstream token system
- OKLCH Color Space - Color space calculator
- MediaWiki Skin Variables - Upstream skin tokens