Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

altcolor

1 sites Security covered
View on drupal.org

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
5 months ago
Release cadence
55 days
Stability
50% stable

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