Theming Guide

SignSure provides a flexible theming system that allows you to customize the appearance to match your brand identity. Choose from built-in themes or create your own custom themes.

Dynamic Theming: SignSure now features dynamic theme loading with performance optimization. The default theme is embedded for instant availability, while additional themes load on-demand.

Built-in Themes

SignSure comes with three professionally designed themes optimized for different use cases. The default theme is always embedded for instant loading, while additional themes are loaded dynamically when needed.

Default Theme

Embedded (~35KB) - Always available instantly

Dark Theme

Dynamic (~24KB) - Loaded on first use

Minimal Theme

Dynamic (~25KB) - Loaded on first use

Default Theme

Clean, professional appearance with blue accents. Perfect for business applications and document workflows.

Dark Theme

Dark mode optimized for low-light environments. Reduces eye strain during extended use.

Minimal Theme

Simplified interface with minimal UI elements. Great for embedded applications and clean layouts.

Using Built-in Themes

SignSure now supports dynamic theme loading. The default theme is always embedded for immediate availability, while additional themes are loaded on-demand for optimal performance.

Dynamic Loading: Only the default theme is embedded in the main bundle. Dark and minimal themes are loaded automatically when first requested.

Initial Theme Selection

Specify the theme when creating a SignSure instance:

// Start with default theme (embedded, no loading time)
const signSure = SignSure.create({
    container: '#pdf-container',
    licenseKey: 'your-license-key',
    theme: 'default'
});

// Start with dark theme (loaded dynamically)
const signSure = SignSure.create({
    container: '#pdf-container',
    licenseKey: 'your-license-key',
    theme: 'dark'
});

// Start with minimal theme (loaded dynamically)
const signSure = SignSure.create({
    container: '#pdf-container',
    licenseKey: 'your-license-key',
    theme: 'minimal'
});

Dynamic Theme Switching

Switch themes at runtime without page reloads:

// Switch to dark theme
await signSure.switchTheme('dark');

// Switch to minimal theme
await signSure.switchTheme('minimal');

// Switch back to default theme
await signSure.switchTheme('default');

// Get current theme
const currentTheme = signSure.getCurrentTheme();
console.log('Current theme:', currentTheme);

Performance Optimization

Preload themes for instant switching:

// Preload themes for better performance
await signSure.preloadThemes(['dark', 'minimal']);

// Now theme switching is instant
await signSure.switchTheme('dark'); // No loading time

// Check if theme is loaded
const isLoaded = signSure.themeManager.isThemeLoaded('dark');
console.log('Dark theme loaded:', isLoaded);

Automatic Theme Switching

Enable automatic theme switching based on system preferences:

// Enable auto theme switching
await signSure.enableAutoTheme({
    dark: 'dark',    // Use dark theme when system prefers dark
    light: 'default' // Use default theme when system prefers light
});

// Check system color scheme
const themeManager = SignSure.getThemeManager();
const systemScheme = themeManager.getSystemColorScheme();
console.log('System prefers:', systemScheme); // 'dark', 'light', or 'no-preference'

Theme Events

Listen for theme changes and loading events:

// Listen for theme changes on SignSure instance
signSure.on('theme-changed', (event) => {
    console.log(`Theme changed to: ${event.theme}`);
});

// Listen for detailed theme events
const themeManager = SignSure.getThemeManager();
const unsubscribe = themeManager.onThemeChange((event, data) => {
    switch (event) {
        case 'theme-changed':
            console.log(`Theme changed from ${data.from} to ${data.to}`);
            break;
        case 'theme-loaded':
            console.log(`Theme loaded: ${data.theme}`);
            break;
        case 'theme-load-error':
            console.error(`Failed to load theme: ${data.theme}`, data.error);
            break;
    }
});

// Unsubscribe when no longer needed
unsubscribe();

Custom Themes

Create custom themes by defining your own color palette and styling options:

Custom Theme Example

const signSure = new SignSure({
    container: '#pdf-container',
    licenseKey: 'your-license-key',
    theme: {
        name: 'corporate',
        colors: {
            primary: '#2563eb',
            primaryDark: '#1d4ed8',
            secondary: '#8b5cf6',
            success: '#10b981',
            warning: '#f59e0b',
            error: '#ef4444',
            background: '#ffffff',
            surface: '#f8fafc',
            border: '#e2e8f0',
            text: '#1e293b',
            textSecondary: '#64748b',
            textMuted: '#94a3b8'
        },
        spacing: {
            xs: '0.25rem',
            sm: '0.5rem',
            md: '1rem',
            lg: '1.5rem',
            xl: '2rem'
        },
        borderRadius: {
            sm: '0.25rem',
            md: '0.5rem',
            lg: '0.75rem',
            xl: '1rem'
        }
    }
});

Color System

SignSure uses a comprehensive color system with semantic color names:

Primary Colors
Primary
#3b82f6
Primary Dark
#2563eb
Primary Light
#dbeafe
Semantic Colors
Success
#10b981
Warning
#f59e0b
Error
#ef4444
Neutral Colors
Text
#1e293b
Text Secondary
#64748b
Border
#e2e8f0

CSS Variables

You can also customize themes using CSS custom properties:

/* Override theme colors with CSS variables */
.signsure-container {
    --signsure-primary: #6366f1;
    --signsure-primary-dark: #4f46e5;
    --signsure-background: #ffffff;
    --signsure-surface: #f8fafc;
    --signsure-border: #e2e8f0;
    --signsure-text: #1e293b;
    --signsure-text-secondary: #64748b;
    --signsure-border-radius: 0.5rem;
    --signsure-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Field-specific styling */
.signsure-field {
    --signsure-field-border: 2px solid var(--signsure-primary);
    --signsure-field-background: rgba(99, 102, 241, 0.05);
    --signsure-field-hover-background: rgba(99, 102, 241, 0.1);
    --signsure-field-selected-background: rgba(99, 102, 241, 0.15);
}

Field Styling

Configure how signature fields appear and behave:

Field Styling Options

const signSure = new SignSure({
    container: '#pdf-container',
    licenseKey: 'your-license-key',
    theme: {
        name: 'custom',
        fieldStyling: {
            // Border styling
            borderWidth: 2,
            borderStyle: 'solid',
            borderColor: '#3b82f6',
            borderRadius: 8,

            // Background
            background: 'rgba(59, 130, 246, 0.05)',
            backgroundHover: 'rgba(59, 130, 246, 0.1)',
            backgroundSelected: 'rgba(59, 130, 246, 0.15)',

            // Shadow
            shadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
            shadowHover: '0 4px 8px rgba(0, 0, 0, 0.15)',

            // Text
            fontSize: '14px',
            fontFamily: 'Inter, sans-serif',
            fontWeight: '500',
            textColor: '#1e293b'
        }
    }
});

Dynamic Theme Switching

Switch themes dynamically at runtime:

// Switch to dark theme
signSure.setTheme('dark');

// Switch to custom theme
signSure.setTheme({
    name: 'corporate',
    colors: {
        primary: '#dc2626',
        primaryDark: '#b91c1c',
        background: '#fef2f2'
    }
});

// Listen for theme changes
signSure.on('theme:changed', (theme) => {
    console.log('Theme changed to:', theme.name);
});

Brand Themes

Create themes that match your brand identity:

// Example: Corporate brand theme
const corporateTheme = {
    name: 'corporate',
    colors: {
        primary: '#1a365d',      // Navy blue
        primaryDark: '#2a4365',  // Darker navy
        secondary: '#e53e3e',    // Red accent
        success: '#38a169',      // Green
        warning: '#d69e2e',      // Orange
        error: '#e53e3e',        // Red
        background: '#ffffff',
        surface: '#f7fafc',
        border: '#e2e8f0',
        text: '#2d3748',
        textSecondary: '#4a5568'
    },
    fonts: {
        primary: 'Corporate Sans, Arial, sans-serif',
        mono: 'Courier New, monospace'
    }
};
Pro Tip: Save your custom themes as separate files and import them to maintain consistency across your applications.

Dynamic Theme Switching

Switch between themes at runtime without page reloads. Themes are cached after first load for instant switching.

// Get available themes
const availableThemes = signSure.getAvailableThemes();
console.log('Available themes:', Object.keys(availableThemes));

// Switch themes dynamically
document.getElementById('theme-selector').addEventListener('change', async (e) => {
    const themeName = e.target.value;
    const success = await signSure.switchTheme(themeName);

    if (success) {
        console.log(`Switched to ${themeName} theme`);
    } else {
        console.error(`Failed to switch to ${themeName} theme`);
    }
});

Performance Optimization

Optimize theme loading for the best user experience:

Bundle Size Optimization

  • Default theme: Embedded in main bundle (~35KB) - No additional load time
  • Dark theme: Loaded on-demand (~24KB) - Only when requested
  • Minimal theme: Loaded on-demand (~25KB) - Only when requested
  • Custom themes: Can be loaded dynamically or embedded
// Preload themes for instant switching
await signSure.preloadThemes(['dark', 'minimal']);

// Check loading status
const themeManager = SignSure.getThemeManager();
console.log('Dark theme loaded:', themeManager.isThemeLoaded('dark'));
console.log('Minimal theme loaded:', themeManager.isThemeLoaded('minimal'));

// Clean up unused themes to save memory
themeManager.cleanupThemes(['dark']); // Keep only current theme + dark theme

Automatic Theme Switching

Enable automatic theme switching based on system preferences:

// Enable auto theme switching
await signSure.enableAutoTheme({
    dark: 'dark',    // Use dark theme when system prefers dark mode
    light: 'default' // Use default theme when system prefers light mode
});

// Manual system detection
const themeManager = SignSure.getThemeManager();
const systemScheme = themeManager.getSystemColorScheme();

switch (systemScheme) {
    case 'dark':
        await signSure.switchTheme('dark');
        break;
    case 'light':
        await signSure.switchTheme('default');
        break;
    default:
        console.log('No system preference detected');
}

Theme Events

Listen for theme-related events to update your UI accordingly:

// Listen on SignSure instance (basic events)
signSure.on('theme-changed', (event) => {
    console.log(`Theme changed to: ${event.theme}`);
    updateUIForTheme(event.theme);
});

// Listen on theme manager (detailed events)
const themeManager = SignSure.getThemeManager();
const unsubscribe = themeManager.onThemeChange((event, data) => {
    switch (event) {
        case 'theme-changed':
            console.log(`Theme: ${data.from} → ${data.to}`);
            break;
        case 'theme-loaded':
            console.log(`Loaded: ${data.theme}`);
            showThemeLoadedNotification(data.theme);
            break;
        case 'theme-load-error':
            console.error(`Load error: ${data.theme}`, data.error);
            showErrorNotification(`Failed to load ${data.theme} theme`);
            break;
        case 'system-theme-change':
            console.log(`System theme changed: ${data.prefersDark ? 'dark' : 'light'}`);
            break;
    }
});

// Cleanup
window.addEventListener('beforeunload', () => {
    unsubscribe();
});

Global Theme Manager

Use the global theme manager to control themes across multiple SignSure instances:

// Get global theme manager
const themeManager = SignSure.getThemeManager();

// Switch themes globally (affects all instances)
await themeManager.switchTheme('dark');

// Get theme information
const currentTheme = themeManager.getCurrentTheme();
const availableThemes = themeManager.getAvailableThemes();
const loadedThemes = Array.from(themeManager.loadedThemes);

console.log('Current:', currentTheme);
console.log('Available:', Object.keys(availableThemes));
console.log('Loaded:', loadedThemes);

// Preload themes globally
const results = await themeManager.preloadThemes(['dark', 'minimal']);
console.log('Preload results:', results);