Speckyboy RSS: Create a Custom Color Palette for the WordPress Gutenberg Editor

Your latest Speckyboy content is here!.

Speckyboy Design Magazine

Design News, Resources & Inspiration

Create a Custom Color Palette for the WordPress Gutenberg Editor


By Eric Karkovack on Aug 18, 2020 08:50 am


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) 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, if necessary.

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

BUILD WORDPRESS SITES FASTER
Announcing Template Kits. Responsive WordPress Designs Built For Elementor.

Disable Custom Colors

It may sound counterintuitive, but the first step is to disable 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.

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 guide.

Define a Block Color Palette

Now that we have stopped users from getting too adventurous with colors, it’s time to define 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.

Also note that this setup requires knowledge of your active theme’s 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.

However, note that in our example images we used it in the default Twenty Twenty theme, which already has a defined color palette. In this case, we simply replaced those existing colors with our new ones.

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.

Another Way to Make WordPress Your Own

WordPress provides theme developers with a number of 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 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.

The post Create a Custom Color Palette for the WordPress Gutenberg Editor appeared first on Speckyboy Design Magazine.



Read in browser »

Recent Articles:

The Kindness of Strangers: Developer Edition
Weekly News for Designers № 553
You’ll Never Be a Design Specialist by Generalizing Your Skills
Embracing Competency and Letting Go of Design Perfection
When Does Using Headless WordPress Make Sense?
Share
Tweet
+1
Share
Forward
Copyright © 2020 Speckyboy Design Magazine, All rights reserved.
You signed up for daily Speckyboy Design Magazine email alerts either via Feedburner or directly through our site.

Our mailing address is:
Speckyboy Design Magazine
27 Braeside Park
Inverness, Scotland IV2 7HL
United Kingdom

Add us to your address book


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.

Older messages

Speckyboy RSS: Weekly News for Designers № 553

Saturday, August 15, 2020

Your latest Speckyboy content is here!. Speckyboy Design Magazine Design News, Resources & Inspiration Weekly News for Designers № 553 By Speckyboy on Aug 14, 2020 05:27 pm Envato Elements Noted –

Speckyboy RSS: You’ll Never Be a Design Specialist by Generalizing Your Skills

Wednesday, August 12, 2020

Your latest Speckyboy content is here!. Speckyboy Design Magazine Design News, Resources & Inspiration You'll Never Be a Design Specialist by Generalizing Your Skills By Addison Duvall on Aug

Speckyboy RSS: Weekly News for Designers № 551

Friday, July 31, 2020

Your latest Speckyboy content is here!. Speckyboy Design Magazine Design News, Resources & Inspiration Weekly News for Designers № 551 By Speckyboy on Jul 31, 2020 10:34 am Envato Elements Shoelace

Speckyboy RSS: How to Troubleshoot WordPress Website Email Issues

Tuesday, July 28, 2020

Your latest Speckyboy content is here!. Speckyboy Design Magazine Design News, Resources & Inspiration How to Troubleshoot WordPress Website Email Issues By Eric Karkovack on Jul 28, 2020 07:06 am

Speckyboy RSS: Do All of the Projects in Your Portfolio Look the Same? That’s OK.

Monday, July 27, 2020

Your latest Speckyboy content is here!. Speckyboy Design Magazine Design News, Resources & Inspiration Do All of the Projects in Your Portfolio Look the Same? That's OK. By Eric Karkovack on

You Might Also Like

What astrology has to do with PR?

Wednesday, November 13, 2024

and, no we won't tell you to read your chart! ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

#482: New Front-End Techniques

Tuesday, November 12, 2024

With high-definition colors, virtual keyboard on mobile, CSS and reliable dialog in HTML. Issue #482 • Nov 12, 2024 • View in the browser Smashing Newsletter Hej Smashing Friends, I remember the good

Mayer Rus on a Malibu Scouting Mission Gone Right

Tuesday, November 12, 2024

View in your browser | Update your preferences ADPro California Dreamin' I should bring my passport, I always think whenever work demands that I leave my cozy nest in Silver Lake to scout a house

Accessibility Weekly #422: Designing Against the Deaf Tax

Monday, November 11, 2024

November 11, 2024 • Issue #422 View this issue online or browse the full issue archive. Featured: Designing against the deaf tax "'Your baby has failed' isn't a phrase any parent wants

Slow Productivity

Sunday, November 10, 2024

Issue 220: Reflections on the new Cal Newport book ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Introducing Brand Presets for Email Templates – Available on All Plans

Saturday, November 9, 2024

Postcards email builder update: mantain your Brand Style across all templates.͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌

Here’s Every 2025 Color of the Year (So Far)

Thursday, November 7, 2024

View in your browser | Update your preferences ADPro Mood of the Moment Color experts are to autumn what Michael Bublé is to the holidays—re-emerging annually in full force to spread seasonal cheer.

Martha Stewart, the Queen of Reinvention

Tuesday, November 5, 2024

View in your browser | Update your preferences ADPro At the book signings for her debut tome, the now-iconic Entertaining published by Clarkson Potter in 1982, Martha Stewart would autograph the inside

#481: Front-End Techniques

Tuesday, November 5, 2024

With text balancing, exclusive accordions, CSS-only validation, responsive video and audio. Issue #481 • Nov 5, 2024 • View in the browser Smashing Newsletter Hej Smashing Friends, As we keep searching

174 / Sketch notes with autumn colors

Tuesday, November 5, 2024

Product Disrupt Logo Product Disrupt Half-Monthly Oct 2024 • Part 2 View in browser Welcome to Issue 174 I'm back from a vacation in Alicante. It's a beautiful coastal city in Spain. We