---
title: "How to Create a Custom Color Palette for the WordPress Gutenberg Editor"
id: "123011"
type: "post"
slug: "custom-color-palette-wordpress-gutenberg-editor"
published_at: "2026-03-18T09:50:04+00:00"
modified_at: "2026-06-13T09:54:43+00:00"
url: "https://speckyboy.com/custom-color-palette-wordpress-gutenberg-editor/"
markdown_url: "https://speckyboy.com/custom-color-palette-wordpress-gutenberg-editor.md"
excerpt: "A custom Gutenberg color palette can keep block layouts on brand and help avoid poor contrast choices. Learn how to set approved colors in functions.php and support them with theme CSS."
taxonomy_category:
  - "WordPress"
  - "WordPress Designer"
taxonomy_post_tag:
  - "Code Snippet"
  - "Learn WordPress"
  - "WordPress Gutenberg"
---

# How to Create a Custom Color Palette for the WordPress Gutenberg Editor

Last Update:  June 13, 2026  
 By  Eric Karkovack

[WordPress](https://speckyboy.com/category/wordpress/)
 / [WordPress Designer](https://speckyboy.com/category/wordpress/wordpress-designer/)

The beauty of the WordPress Gutenberg block editor is that it allows content creators more design freedom. But for web designers, it’s not always desirable to give clients access to certain features.

Color palettes are one such area of concern. A client with access to the entire rainbow might inadvertently do more harm than good. Beyond diverging from your carefully chosen colors, there could also be a negative impact when it comes to accessibility.

Fortunately, WordPress provides a way for designers to limit the colors available within the block editor. This ensures that blocks stay within branding guidelines and might (with a little [guidance](https://speckyboy.com/clients-role-in-website-accessibility/)
) help to prevent those undesirable contrast issues.

To take away that rainbow and define your own colors, it requires adding a bit of code to your WordPress theme. Everything will take place in your theme’s `functions.php` file. As always, make sure you back up your work and use a [child theme](https://speckyboy.com/wordpress-child-themes/)
, if necessary.

This guide will show you how to take control of the WordPress color palette. Let’s get started!

## Disable Custom Colors

It may sound counterintuitive, but the first step is to [disable](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/)
 the block editor’s ability to use custom colors. This essentially turns off the editor’s color picker, thus preventing users from selecting just any old hue.

![The WordPress custom color picker.](https://speckyboy.com/wp-content/uploads/2020/08/wp-block-color-palette-01.jpg)

To accomplish this, add the following snippet to your theme’s `functions.php` file. And while we’re at it, let’s also turn off Gutenberg’s custom gradients feature as well.

For neatness, this snippet would ideally be wrapped within an existing function, along with other theme support settings. If your theme doesn’t have an existing function, you’ll have to create your own. For more details, check out the [WordPress Theme Support](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/)
 guide.

## Define a Block Color Palette

Now that we have stopped users from getting too adventurous with colors, it’s time to [define](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/)
 the palette we want them to utilize. In this step, it’s important to consider not only the colors your site uses for branding but also some generic colors you may want to implement.

For example, perhaps black and white aren’t necessarily tied to your brand – but they may still need to be used throughout your website. As we’ve taken the color picker away, we’ll want to include any and all colors that are needed within the editor.

![A custom color palette within the WordPress block editor.](https://speckyboy.com/wp-content/uploads/2020/08/wp-block-color-palette-02.jpg)

Also note that this setup requires knowledge of your active theme’s [text domain](https://developer.wordpress.org/themes/classic-themes/functionality/internationalization/#text-domain)
. In the code snippet below, you’ll want to replace all instances of `textdomain` with the one specific to your theme.

Once again, this snippet will go into `functions.php`, within an existing function if available. It also assumes that your theme doesn’t already have colors defined.

For each color, we must define three attributes:

- `name`;
- `slug`;
- `color`;

The `name` is the label that will be displayed for this color within the block editor. The `slug` will be used to assign CSS classes to blocks that use this particular color. Finally, `color` is the hexadecimal code used to define the color itself.

Now, we can apply background and text colors to blocks within our website.

![A Gutenberg block with custom colors applied.](https://speckyboy.com/wp-content/uploads/2020/08/wp-block-color-palette-03.jpg)

Note that each custom color must also be defined within your theme’s CSS. The slug of your custom color will be included in classes for color `has-slug-color` and background color `has-slug-background-color`.

For example, for a color defined in your palette as “blue”, we’d create classes for:

- `.has-blue-color`
- `.has-blue-background-color`

In practice, this would look like:

```
.has-blue-color {
  color:#347ab7;
}
.has-blue-background-color {
    background-color:#347ab7;
}
```

These definitions may also be added to a custom [editor stylesheet](https://codex.wordpress.org/Editor_Style)
 for further tweaking, although WordPress will show them on the back end without this step.

## Another Way to Make WordPress Your Own

WordPress provides theme developers with several ways to customize their work. Creating a custom color palette may seem like a minor feature, but it accomplishes a couple of things.

First, it’s a simple way to [client-proof](https://speckyboy.com/client-proof-wordpress-websites/)
 your projects. By offering up only a limited number of colors, you can prevent clients from going rogue with how content looks.

In addition, a custom color palette is also a major convenience for content creators. Without one, they may have to search around (or worse – ask you) for hexadecimal codes for various brand colors. Now, they’ll have everything they need right within the block editor.

All told, it’s another feature that you can use to build a website to suit the specific needs of your clients.

## Related Articles

- [How to Improve Custom Layouts Using the WordPress Block Editor](https://speckyboy.com/enhance-custom-layouts-wordpress-block-editor/) We share three methods to enhance custom layouts with the WordPress block editor. Turn something basic into a highly-customized setup.
- [How to Build a Custom WordPress Block With Telex](https://speckyboy.com/build-custom-wordpress-block-with-telex/) Learn how Telex from Automattic helps you build custom WordPress blocks with plain language prompts, test them in Playground, and export them as installable plugins.
- [An Introduction to WordPress Block Themes](https://speckyboy.com/introduction-wordpress-block-themes/) An introduction into the basics of WordPress block themes, and discussion on how they compare and contrast to traditional themes.
- [How to Hide WordPress Blocks Based on Device](https://speckyboy.com/how-to-hide-wordpress-blocks-based-on-device/) WordPress 7.0 adds responsive Block Visibility controls for the Block Editor. Learn how to create separate desktop and mobile blocks, hide each one by device, and test the result.
- [Quick Tip: How To Use WordPress Block Notes](https://speckyboy.com/wordpress-block-notes/) WordPress Notes adds block level comments to the Block Editor. We show you how to add a note to any block, reply in a thread, get email notifications, and mark notes as resolved for smoother collaboration.

## Related Topics

- [Code Snippet](https://speckyboy.com/topic/code-snippet/)
- [Learn WordPress](https://speckyboy.com/topic/learn-wordpress/)
- [WordPress Gutenberg](https://speckyboy.com/topic/wordpress-gutenberg/)

## Written by Eric Karkovack

Eric Karkovack is a web designer and WordPress expert with over two decades of experience. You can visit his business site [here](https://www.karks.com/)
. He recently started a writing service for WordPress products: [WP Product Writeup](https://wpproductwriteup.com/)
. He also has an opinion on just about every subject. You can follow his rants on Bluesky [@karks.com](https://bsky.app/profile/karks.com)
.

[Read more articles by Eric Karkovack](https://speckyboy.com/author/erickarkovack/)

---

Top

This page may contain affiliate links. At no extra cost to you, we may earn a commission from any purchase via the links on our site. You can [read our Disclosure Policy](https://speckyboy.com/affiliate-disclosure/)
 at any time.
