← Retour à Theming

Création de thèmes personnalisés avec override de variables

BUILDERTheme Builder Interface

Interface visuelle pour créer des thèmes personnalisés

interface ThemeBuilder {
  colors: {
    primary: ColorPicker;
    secondary: ColorPicker;
    accent: ColorPicker;
    background: ColorPicker;
  };
  typography: {
    fontFamily: FontSelector;
    fontSizes: SizeScale;
    fontWeights: WeightScale;
  };
  spacing: SpacingScale;
  borderRadius: RadiusScale;
  shadows: ShadowPresets;
}
EXAMPLESExemples de Thèmes Personnalisés

Thèmes préconstruits pour inspiration et utilisation directe

Ocean Theme

Primary: #3B82F6
Secondary: #14B8A6
Accent: #06B6D4
Surface: #0F172A

Forest Theme

Primary: #16A34A
Secondary: #059669
Accent: #10B981
Surface: #064E3B

Sunset Theme

Primary: #F97316
Secondary: #EF4444
Accent: #F59E0B
Surface: #7C2D12
CSSSystème d'Override CSS

Override sélectif de variables CSS pour personnalisation fine

/* Custom Theme: Ocean */
[data-theme="ocean"] {
  --primary: 214 100% 59%;
  --primary-foreground: 210 40% 98%;
  --secondary: 165 93% 41%;
  --secondary-foreground: 210 40% 98%;
  --accent: 189 94% 43%;
  --accent-foreground: 210 40% 98%;
  --background: 222 84% 5%;
  --surface: 217 33% 17%;
}

/* Custom Theme: Forest */
[data-theme="forest"] {
  --primary: 142 76% 36%;
  --secondary: 160 84% 39%;
  --accent: 156 72% 67%;
  --background: 164 76% 15%;
  --surface: 160 76% 20%;
}
GUIDEGuide d'Implémentation

Étapes pour créer et déployer un thème personnalisé

1. Planification

  • • Définir la palette de couleurs
  • • Choisir la typographie
  • • Établir les espacements
  • • Sélectionner les ombres

2. Développement

  • • Créer le fichier CSS
  • • Override les variables
  • • Tester l'accessibilité
  • • Valider la cohérence

3. Test & QA

  • • Contraste des couleurs
  • • Lisibilité des textes
  • • Responsive design
  • • Performance loading

4. Déploiement

  • • Documentation complète
  • • Exemples d'usage
  • • Migration guide
  • • Support utilisateur
JSBasculement Dynamique

JavaScript pour changer de thème à la volée

function setCustomTheme(themeName: string) {
  // Remove existing theme
  document.documentElement.removeAttribute('data-theme')

  // Apply new theme
  document.documentElement.setAttribute('data-theme', themeName)

  // Save preference
  localStorage.setItem('custom-theme', themeName)

  // Emit theme change event
  window.dispatchEvent(new CustomEvent('theme-changed', {
    detail: { theme: themeName }
  }))
}

// Theme selector component
export function ThemeSelector() {
  const themes = ['default', 'ocean', 'forest', 'sunset']

  return (
    <select onChange={(e) => setCustomTheme(e.target.value)}>
      {themes.map(theme => (
        <option key={theme} value={theme}>
          {theme.charAt(0).toUpperCase() + theme.slice(1)}
        </option>
      ))}
    </select>
  )
}