Skip to main content

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:

  • :root holds the light theme.
  • .docapply-dark-mode, .docapply-blossom and .docapply-aquabloom only 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>, plus data-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​

  1. Tailwind classes first β€” Most common scenarios
  2. Semantic token variables (var(--color-*)) β€” When Tailwind doesn't provide what you need
  3. 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​

CategoryTailwind ClassesCSS VariablesUse Case
Primarytext-primary-default, bg-primary-hover--color-primary-defaultPrimary actions, brand colors
Secondarytext-secondary-default, bg-secondary-hover--color-secondary-defaultSecondary actions
Texttext-text-primary, text-text-secondary--color-text-primaryText hierarchy
Backgroundbg-background-default, bg-background-surface--color-background-defaultSurfaces, cards
Borderborder-border-default--color-border-defaultBorders, dividers
Semantictext-positive-default, text-negative-default--color-positive-default, --color-negative-defaultSuccess, 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.

warning

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 theme
  • dark β€” Dark mode
  • blossom β€” Custom theme variant
  • aquabloom β€” Alternative theme variant

  • 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/