Skip to content

feat: enhance ThemeProvider customization capabilities #578

@ravisuhag

Description

@ravisuhag

Summary

Enhance the ThemeProvider to support comprehensive theming customization, making Apsara more adaptable to different design requirements and use cases.

Current Capabilities

The ThemeProvider already handles:

  • Theme mode (light / dark / system)
  • Style variants (modern / traditional)
  • Accent colors (indigo / orange / mint)
  • Gray scales (gray / mauve / slate / sage)
  • Persistence via localStorage
  • System preference detection
  • FOUC prevention with inline script

Proposed Enhancements

1. Scaling/Density

scaling: 'compact' | 'default' | 'comfortable' | 'spacious'

Adjusts spacing tokens globally for different UI densities. Useful for data-dense applications vs content-focused interfaces.

2. Border Radius Control

radius: 'none' | 'small' | 'medium' | 'large' | 'full'

Global control over component roundness beyond style variants. Allows sharp corners for enterprise apps or pill-shaped components for playful designs.

3. Typography Scale

fontFamily: { body: string; heading: string; mono: string }
fontSize: 'small' | 'default' | 'large'  // Base scale multiplier

Allow consumers to customize font families and adjust the base font size scale.

4. Custom Token Overrides

tokens: {
  colors?: Partial<ColorTokens>
  spacing?: Partial<SpacingTokens>
  radius?: Partial<RadiusTokens>
  shadows?: Partial<ShadowTokens>
}

Allow consumers to override any design token for brand-specific customization.

5. Component-Level Defaults

components: {
  Button?: { variant?: 'solid' | 'outline'; size?: 'sm' | 'md' }
  Input?: { variant?: 'default' | 'soft' }
  // etc.
}

Set default props for components at the theme level, reducing repetition across the app.

6. Animation Control

reducedMotion: boolean | 'system'
transitionDuration: 'none' | 'fast' | 'default' | 'slow'

Respect user accessibility preferences and allow global animation speed control.

7. Nested Appearance Mode

appearance: 'light' | 'dark' | 'inherit'  // Per-subtree theming

Allows nested theme contexts with different modes (e.g., dark sidebar in light app).

8. Panel Background Mode

panelBackground: 'solid' | 'translucent'  // For glassmorphism effects

Support for modern translucent/blur backgrounds on panels, cards, and overlays.

Suggested Interface

interface ThemeProviderProps {
  // Existing
  theme?: 'light' | 'dark' | 'system'
  style?: 'modern' | 'traditional'
  accentColor?: 'indigo' | 'orange' | 'mint' | string
  grayColor?: 'gray' | 'mauve' | 'slate' | 'sage'
  
  // New capabilities
  scaling?: 'compact' | 'default' | 'comfortable' | 'spacious'
  radius?: 'none' | 'small' | 'medium' | 'large' | 'full'
  reducedMotion?: boolean | 'system'
  transitionDuration?: 'none' | 'fast' | 'default' | 'slow'
  panelBackground?: 'solid' | 'translucent'
  
  // Advanced customization
  tokens?: DeepPartial<DesignTokens>
  components?: ComponentDefaults
  
  // Configuration
  storageKey?: string
  disableTransitionOnChange?: boolean
}

Implementation Notes

  • All new props should have sensible defaults to maintain backward compatibility
  • CSS variables should be the primary mechanism for runtime theming
  • Consider generating CSS at build time for static themes to improve performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions