Theme Architecture
The theming system is built on several layers:- Base tokens - Core design tokens shared across all themes
- Theme-specific tokens - Color values that change between light and dark modes
- Codex design tokens - MediaWiki’s design system integration
- Citizen-specific tokens - Custom tokens for Citizen features
Theme Files
The theme system is organized in the following files:resources/skins.citizen.styles/tokens.less- Main entry pointresources/skins.citizen.styles/tokens-citizen.less- Citizen-specific tokensresources/skins.citizen.styles/tokens-codex.less- Codex design tokensresources/skins.citizen.styles/tokens-theme-base.less- Light theme (base)resources/skins.citizen.styles/tokens-theme-dark.less- Dark theme
Theme Selection
Users can select their preferred theme through the skin preferences menu. The default theme can be configured inLocalSettings.php:
auto option respects the user’s system preference via prefers-color-scheme.
Creating a Custom Theme
Method 1: Override CSS Variables
The simplest way to customize the theme is to override CSS variables in your own stylesheet:Method 2: Create a Custom Theme LESS File
For more comprehensive theming, create a new LESS file:Theme Color System
OKLCH Color Space
Citizen uses the OKLCH color space for better color perception and manipulation:- L (Lightness): 0% to 100%
- C (Chroma): 0 to ~0.4 (saturation)
- H (Hue): 0 to 360 degrees
Progressive Color
The “progressive” color is the primary accent color used throughout the theme:Surface Colors
Surface colors create depth and hierarchy:--color-surface-0- Base background--color-surface-1- Slightly elevated elements--color-surface-2- More elevated elements--color-surface-3- Cards and panels--color-surface-4- Top-level elevated content
Dark Theme Customization
Dark theme uses different lightness values to ensure proper contrast:State Colors
Customize interactive state colors:Theme Configuration
Additional theme settings can be configured inskin.json or LocalSettings.php:
Best Practices
- Test both themes - Always test your customizations in both light and dark modes
- Maintain contrast - Ensure sufficient contrast ratios (WCAG AA minimum: 4.5:1)
- Use semantic colors - Leverage the existing color system rather than hardcoding values
- Progressive enhancement - Provide HSL fallbacks for OKLCH colors
- Respect user preferences - Don’t override system theme preferences unless necessary
Examples
Brand Color Integration
High Contrast Theme
Custom Dark Theme
Related
- CSS Variables - Complete reference of all CSS variables
- Resource Loader - How to load custom stylesheets