Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Altcolor provides a modern way for themes to allow users to customize colors. It enables users to easily adapt a theme's appearance to match their brand by letting them change specific color values defined by the theme.

This module is a modern alternative to the deprecated Color module that used to be in Drupal core. It allows supported themes to be recolored and to display the theme in an alternative color. This makes it easy for users to adapt a theme to match the colors of their brand or logo.

Requirements

This module requires a supported theme. That is a theme with a THEME.colors.yml file which would look something like this:

THEMENAME:
  colors:
    base_primary_color: 'Primary base color'

  schemes:
    default:
      label: 'Blue Lagoon'
      colors:
        base_primary_color: '#1b9ae4'

Working

This module will read the color information as defined by the theme builder. It will then allow the user to change these colors on the theme settings page and inject these colors back into the page as CSS variables.
The above colors file will inject in the HTML style tag as follows:

<html style="--color-base-primary-color: #1b9ae4;">

Theme builders

Theme builders can use this to make it easy for their users to display a theme in their own brand colors by making use of the same CSS variables.

:root {
  --color-base-primary-color: yellow;
}

body {
  background-color: var(--color-base-primary-color);
}

After the color is changed on the theme settings form, the value defined in the style tag will take precedence over the yellow that was defined in the CSS file and the background will be blue (#1b9ae4) instead.

This makes it very easy to make a theme compatible. All that a theme developer needs to do is to write the THEME.colors.yml and define color variables as --color-VARNAME. No need to write additional CSS/JS as with the previous color module.

Derived (relative) colors

The CSS color module 5 standard describes relative colors, which offers the ability to create one color based on another. This makes it easier to for example lighten a color in pure CSS:

:root {
  --color-base-primary-color: #1b9ae4;
  --color-base-primary-color-light: hsl(from var(--color-base-primary-color) h s calc(l + 10%));
}

Browser support for relative colors is growing steadily. Should you need legacy browser support, the hook_altcolor_alter_colors hook can be used to add additional derived colors directly in the style tag. Third party PHP libraries can be used to modify colors (shift hue, lighten, darken, etc).

function HOOK_altcolor_alter_colors($theme, &$colors) {
  $base_primary_color = $colors['base-primary-color'];

  // Caclulate a lighter color with third party library.
  $base_primary_color_light = 'SOME_COLOR';

  // Add additional colors to the array. 
  // Make derived --color-base-primary-color-light available in the CSS.
  $colors['base-primary-color-light'] = $base_primary_color_light;
}

Activity

Total releases
4
First release
May 2025
Latest release
8 months ago
Releases (12 mo)
2
Maintenance
Slowing

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Oct 22, 2025
1.0.0 Stable Oct 21, 2025
1.0.0-beta1 Pre-release May 29, 2025
1.x-dev Dev May 10, 2025