Color

Swatches

  • Add the core swatches used in the design

  • Add extra variables if needed for styles like brand-secondary-500, brand-secondary-text, and so on.

Whenever --swatch--brand-500 is applied as a background color, --swatch--brand-text is applied as its font color. If the brand color ever needs to change in the future to a darker color that requires light text, we can update that brand-text color from one place.

Theme variable collection

  • Set the section's background, text, & border colors across all modes

  • Set the primary (solid) & secondary (outlined) button styles across all modes

  • Add additional folders inside the Theme collection if needed for styles like card/background, input/border-hover, input/border-focus, and so on.

Button Style variable collection

  • Reference the button styles created in the Theme collection so that each button style automatically updates in both light and dark mode.

  • Add any additional button style modes if needed.

  • Apply these button style variables to any buttons

Connecting Button Style to Component Props

  1. Create a component variant for the secondary button style

  2. Switch the mode to the secondary mode

Connecting Theme to Component Props

1. Create component variants for Inherit, Light, Dark, and any other themes

The inherit variant should have no theme applied. It will inherit the theme of the page.

2. Apply the theme/text variable and theme/background variable to the base variant

Animating between themes with GSAP

  • This script retrieves all variables from the Theme variable collection.

  • Any classes starting with "u-theme-" will be included as themes we can animate between.

  • Any classes starting with "u-brand-" will be included as brands we can animate between.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/lumosframework/[email protected]/theme-collector.js"></script>
<script>
document.addEventListener("colorThemesReady", () => {
  gsap.to(".my-element", { ...colorThemes.getTheme("dark", "3") });
});
</script>

With Per Page CSS

If using Per Page CSS, use this version instead and ensure the u-theme- classes are included on every page of your site.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/lumosframework/[email protected]/themecollector.js"></script>
<script>
document.addEventListener("colorThemesReady", () => {
  gsap.to(".my-element", { ...colorThemes.getTheme("dark", "3") });
});
</script>

If we have classes of u-theme-dark and u-brand-orange, we can animate to those modes like so...

document.addEventListener("colorThemesReady", () => {
  gsap.to(".my-element", { ...colorThemes.getTheme("dark", "orange") });
});

If we only have theme classes and no brand classes, we can animate between themes like so...

document.addEventListener("colorThemesReady", () => {
  gsap.to(".my-element", { ...colorThemes.getTheme("dark") });
});

Light Mode / Dark Mode Switcher

Last updated

Was this helpful?