Logo
NeoArc Studio

Theming System

Configure light and dark themes for published sites. The theming system provides consistent styling across all viewer components with automatic persistence and CSS variable support.

Published NeoArc sites include a full theming system with light and dark modes. The theme affects all viewer components including pages, diagrams, code blocks, and API documentation. User preference persists across sessions.

Theme Modes

Light Mode
White backgrounds, dark text, optimised for daytime use and printing
Dark Mode
Dark backgrounds, light text, optimised for low-light environments and reduced eye strain

User Controls

Readers can toggle the theme using:

Theme Persistence

Theme selection persists in the browser's localStorage:

StorageKeyValues
localStorageneoarc-theme"light" or "dark"
Initial value(none)Uses system preference
After toggleStored preferenceOverrides system preference

Color Palette

Each theme defines a complete colour palette for consistent styling across components.

Background Colors

TokenLightDarkUsage
bgPrimary#FFFFFF#1a1a1aMain content background
bgSecondary#F5F5F5#2d2d2dSecondary panels, cards
bgTertiary#EEEEEE#3d3d3dTertiary backgrounds

Text Colors

TokenLightDarkUsage
textPrimary#1a1a1a#FFFFFFMain text
textSecondary#666666#A0A0A0Secondary text, captions
textTertiary#999999#707070Muted text, placeholders

Component Colors

ComponentColor Tokens
Top BartopBarBg, topBarText, topBarHover
SidebarsidebarBg, sidebarItemHover, sidebarItemActive
Code BlockscodeBg, codeText
DiagramsdiagramBg, diagramBorder
BordersborderPrimary, borderSecondary

HTTP Method Badge Colors

REST API documentation uses method-specific colours:

MethodLight BackgroundDark Background
GET#dcfce7 (green)#166534
POST#dbeafe (blue)#1e40af
PUT#fef3c7 (yellow)#92400e
PATCH#fef3c7 (yellow)#92400e
DELETE#fee2e2 (red)#991b1b

Status Code Colors

HTTP status codes are colour-coded:

RangeLight BackgroundMeaning
2xxGreenSuccess responses
3xxBlueRedirect responses
4xxYellow/OrangeClient errors
5xxRedServer errors

CSS Custom Properties

Theme colours are exposed as CSS custom properties for custom styling:

/* Example: Using theme variables in custom CSS */
.my-custom-component {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.my-custom-component:hover {
  background-color: var(--hover-bg);
}

ThemeService API

The theme service provides programmatic access for custom components:

import { themeService } from './services/theme';

// Get current mode
const mode = themeService.getCurrentMode(); // 'light' or 'dark'

// Get current color palette
const colors = themeService.getCurrentColors();
console.log(colors.bgPrimary, colors.textPrimary);

// Toggle theme
themeService.toggle();

// Set specific mode
themeService.setMode('dark');

// Subscribe to changes
themeService.subscribe((mode, colors) => {
  console.log('Theme changed to:', mode);
});

Diagram Theme Integration

Embedded diagrams automatically respect the current theme:

WCAG Compliance

Theme colours are designed for WCAG AA contrast compliance:

RequirementStandardStatus
Normal text contrast4.5:1 minimumCompliant
Large text contrast3:1 minimumCompliant
Interactive element focusVisible focus indicatorsCompliant
Colour not sole indicatorText/icons supplement colourCompliant