Color Theming
DocApply's theming is built on plain CSS custom properties and Tailwind CSS v4. It supports four themes (light, dark, blossom, aquabloom), follows the system's dark mode preference, and switches without a reload.
ποΈ Architecture Overviewβ
Theme Palette (Single Source of Truth)β
src/main/webapp/content/scss/_palette.scss
Defines the colour values of every theme as --palette-* custom properties:
:rootholds the light theme..docapply-dark-mode,.docapply-blossomand.docapply-aquabloomonly list the values that differ from light.
Tailwind Integrationβ
src/main/webapp/content/scss/_tokens.scss
Maps the palette to semantic Tailwind color tokens, so utility classes follow the active theme.
@theme {
--color-primary-default: var(--palette-primary-color);
--color-text-primary: var(--palette-text-primary);
--color-background-default: var(--palette-background-default);
// ... etc.
}
UI Kit Integrationβ
src/main/webapp/content/scss/_tumaet-ui-theme.scss
Points the TUM AET UI kit's --tumaet-ui-* variables at the semantic tokens, so kit components follow the active theme too.
Global Stylesβ
src/main/webapp/content/scss/global.scss
@use 'tailwindcss' as *;
@use './tokens' as *;
@use './palette';
@use './tumaet-ui-theme';
@custom-variant dark (&:where(.docapply-dark-mode, .docapply-dark-mode *));
Theme Serviceβ
src/main/webapp/app/service/theme.service.ts
- Manages theme switching (light, dark, blossom, aquabloom)
- Syncs with system preferences via
prefers-color-scheme - Persists user preference in
localStorage - Applies a theme by setting its class on
<html>, plusdata-theme="dark"for the UI kit in dark mode
β Best Practicesβ
1. Always Use Semantic Colorsβ
β Use Tailwind utility classes (PREFERRED):
<div class="text-primary-default bg-background-surface border-border-default">
<span class="text-text-secondary">Secondary text</span>
</div>
β Use the semantic token variables (for custom SCSS):
.custom-element {
color: var(--color-text-primary);
background-color: var(--color-background-default);
border-color: var(--color-border-default);
}
β NEVER use hard-coded hex values:
<div style="color: #3070b3;">...</div>
2. Styling Priorityβ
- Tailwind classes first β Most common scenarios
- Semantic token variables (
var(--color-*)) β When Tailwind doesn't provide what you need - Custom SCSS β Only when neither option works
3. Dark Mode Supportβ
Use Tailwind's dark: variant with the custom dark mode selector:
<div
class="bg-background-default text-text-primary
dark:bg-background-surface dark:text-text-secondary"
>
Adapts to theme automatically
</div>
The dark: variant works with the .docapply-dark-mode class applied to <html>.
4. Available Color Categoriesβ
| Category | Tailwind Classes | CSS Variables | Use Case |
|---|---|---|---|
| Primary | text-primary-default, bg-primary-hover | --color-primary-default | Primary actions, brand colors |
| Secondary | text-secondary-default, bg-secondary-hover | --color-secondary-default | Secondary actions |
| Text | text-text-primary, text-text-secondary | --color-text-primary | Text hierarchy |
| Background | bg-background-default, bg-background-surface | --color-background-default | Surfaces, cards |
| Border | border-border-default | --color-border-default | Borders, dividers |
| Semantic | text-positive-default, text-negative-default | --color-positive-default, --color-negative-default | Success, error, warning states |
5. Common Patternsβ
Card/Panel:
<div class="bg-background-surface border border-border-default rounded-lg p-4">
<h3 class="text-text-primary font-semibold">Title</h3>
<p class="text-text-secondary text-sm">Description</p>
</div>
Status Indicators:
<span class="text-positive-default">Success</span>
<span class="text-negative-default">Error</span>
<span class="text-warning-default">Warning</span>
Interactive Elements:
<button
class="bg-primary-default text-text-on-primary
hover:bg-primary-hover active:bg-primary-active"
>
Click me
</button>
π¨ Theme Customizationβ
Modifying Existing Themesβ
Edit the values in src/main/webapp/content/scss/_palette.scss. A change in :root applies to every theme that does not override that value; a theme class overrides it only for that theme.
When you add a new palette value, give it a light value in :root and check whether dark, blossom and aquabloom need their own. Then map it to a semantic token in _tokens.scss instead of using it directly.
UI Kit Componentsβ
The TUM AET UI kit's theme variables are mapped to these tokens in content/scss/_tumaet-ui-theme.scss. For styling kit components, see the Client Styling page.
Adding New Tailwind Tokensβ
Add a token only when no existing token fits. Every token must work in every theme, so check its palette value in light, dark, blossom and aquabloom first.
Edit: src/main/webapp/content/scss/_tokens.scss
@theme {
--color-custom-highlight: var(--palette-primary-200);
// Now use: class="bg-custom-highlight"
}
π Theme Switchingβ
Users can switch themes via the UI. The ThemeService handles:
- Theme persistence in localStorage
- System preference synchronization
- CSS class application (
.docapply-dark-mode,.docapply-blossom,.docapply-aquabloom) data-theme="dark"for the TUM AET UI kit
Available themes:
lightβ Default light themedarkβ Dark modeblossomβ Custom theme variantaquabloomβ Alternative theme variant
π Related Documentationβ
- See Client Styling for styling best practices
- See Client Development for Angular and TypeScript patterns
- Component library structure in
src/main/webapp/app/shared/components/