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

[Reminder] UpLabs Shutting Down on June 1st

Tuesday, May 14, 2024

Dear customer, We hope this message finds you well. It is with a heavy heart and, after much deliberation, that we must announce the upcoming closure of UpLabs. Our last day of operation will be June

If you want editors to open your emails...

Tuesday, May 14, 2024

... here's a quick tip to improve your pitch subject lines. A quick ask before we get into it. Our friends over at Proof to Product working on a report to help product folks make better business

Old Decorating Ideas We Wish They’d Bring Back

Tuesday, May 14, 2024

View in your browser | Update your preferences ADPro In AD PRO's newest feature on the potential pendulum swing towards 2000s interior design, AD100 talent Martyn Lawrence Bullard recommends “a

Update #61: Postcards Email Builder Update & New Email Templates

Tuesday, May 14, 2024

Here are the most recent Designmodo apps updates and releases from the past month.͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌

#456: How to Name Things

Tuesday, May 14, 2024

How to name design tokens, colors, UI components, HTML classes and variables. Issue #456 • May 14, 2024 • View in the browser Smashing Newsletter Konbanwa Smashing Friends, Naming is hard. As designers

Headless UI, Particle Shader Effect, Range Syntax, State of HTML, Custom @property

Tuesday, May 14, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar May 14 2024 OpenAI Spring Update openai.com Introducing GPT-4o

OpenAI Spring Update, CSS Shapes, Humane Web, useDeferredValue, Complicated Sticks

Tuesday, May 14, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar May 13 2024 OpenAI Spring Update openai.com Introducing GPT-4o

🏡 Superb Real Estate Web Designs + 🏆 Challenge Updates

Monday, May 13, 2024

Find out what's new in the UpLabs community this week 👇 Firstly, let's congratulate Rahul Parmar, the winner of our latest 📧 E-mail Client Challenge! Congratulations!! Secondly, don't

Accessibility Weekly #396: Global Accessibility Awareness Day 2024

Monday, May 13, 2024

May 13, 2024 • Issue #396 View this issue online or browse the full issue archive. Featured: Global Accessibility Awareness Day is Thursday "Thursday, May 16, 2024, help us celebrate the 13th

Concept to keynote with Figma and Google Docs

Sunday, May 12, 2024

Issue 194: Taking a keynote presentation from concept to production ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏