Stand with Ukraine 🇺🇦
Products
Services
Blog
About Us

Writing User Macros Compatible with Dark Theme

Confluence supports dark theme across the product, and user macros created using User Macro for Confluence Cloud app are designed to inherit this behavior automatically.
That means in most cases, your user macro will already look correct in both Light and Dark modes without any extra work.

Atlassian recommends using Design Tokens (tokenized CSS variables) instead of hardcoded visual values, because tokens automatically adapt when the active theme changes.


Good news: Default user macro styles are already theme-aware

If your macro uses:

  • standard HTML elements

  • inherited fonts

  • default text color

  • default backgrounds

  • AUI components

then the app will automatically apply the correct colors.

Here’s an example which requires no additional dark-theme adaptation:

image-20260505-105642.png

When dark theme problems usually appear

Issues start only when use macro authors introduce:

  • custom background colors

  • custom text colors

  • borders

  • shadows, etc.

Example of problematic code:

<div style="background: #ffffff; color: #222; border: 1px solid #ccc;">
    Custom panel content
</div>
{"timestamp":1792799681446,"msg":"A unknown Exception Occurred","errorMsg":"The provided AtlassianHostUser did not specify a user to act as.","code":"500"}

Important limitation for static content macros

While Atlassian Design Tokens are the recommended way to make custom styling theme-aware, please note that static content macros do not always support the full Atlassian Design System variable set.

Because static macros are rendered inside Confluence page content rather than inside a full Atlassian application runtime (iframe), availability of certain --ds-* CSS variables may vary depending on:

  • Confluence version

  • rendering context

  • surrounding DOM inheritance

In practice, this means:

  • some commonly used surface, text, border, and spacing tokens usually work well

  • but some newer or more context-specific tokens may not resolve as expected

{"timestamp":1792799681445,"msg":"A unknown Exception Occurred","errorMsg":"The provided AtlassianHostUser did not specify a user to act as.","code":"500"}

Recommended approach: Use Atlassian CSS variable-Based design tokens

Atlassian provides a full set of design tokens exposed as CSS custom properties (var(--ds-...)).

These tokens are specifically created to:

  • automatically switch between light/dark values

  • stay visually consistent with native Confluence UI

  • support accessibility contrast requirements

  • remain future-proof as Atlassian updates themes

You can browse the full token library here:


Commonly used tokens

Purpose

Recommended Token

CSS Variable

Default text

color.text

var(--ds-text)

Subtle text

color.text.subtle

var(--ds-text-subtlest)

Main surface

color.background.neutral

var(--ds-background-neutral)

Raised card/panel

elevation.surface.raised

var(--ds-surface-raised)

Border

color.border

var(--ds-border)

Selected/accent background

color.background.selected

var(--ds-background-selected)

Information background

color.background.information

var(--ds-background-information)

Success background

color.background.success

var(--ds-background-success)

Warning background

color.background.warning

var(--ds-background-warning)

Danger background

color.background.danger

var(--ds-background-danger)

Standard spacing

space.100 / 200 / 300

var(--ds-space-100) etc


Use case: Dark theme safe custom panel

❌ Not Recommended

<div style="
    background: #f4f5f7;
    color: #172b4d;
    border: 1px solid #dfe1e6;
    padding: 12px;
">
    $body
</div>

✅ Recommended

<div style="
    background: var(--ds-surface-raised);
    color: var(--ds-text);
    border: 1px solid var(--ds-border);
    padding: var(--ds-space-200);
    border-radius:4px;
">
    $body
</div>