Contact!

Changing the width of the WordPress Gutenberg editor

Gutenberg editor width

There are many things which irritate me about working with WordPress, but one of my biggest annoyances is the default width of the Gutenberg editor. The default width is 610px, which I personally find to be far too narrow for desktop use. It seems a strange design choice, but I’m sure WordPress have their reasons.

Luckily, there is an easy fix. We’re going to inject some admin styles to override the width.

Navigate to a functions.php file in either your theme or custom plugin (WordPress plugin skeleton). Here we are going to add the following function:

function gb_gutenberg_admin_styles() {
    echo '
        <style>
            /* Main column width */
            .wp-block {
                max-width: 720px;
            }
 
            /* Width of "wide" blocks */
            .wp-block[data-align="wide"] {
                max-width: 1080px;
            }
 
            /* Width of "full-wide" blocks */
            .wp-block[data-align="full"] {
                max-width: none;
            }	
        </style>
    ';
}

The idea is that we want to call this function when the admin head is loaded so that the enclosed style tags are echoed into the head. To do this we can add an action to call the code in the admin head.

add_action('admin_head', 'gb_gutenberg_admin_styles');

Play with the max-width numbers until you find the perfect width for you. Happy blogging!

For those of you as lazy as I am, I’ve added a simple plugin to GitHub for you.

  1. Esa Mäkelä says:

    wouldnt this be better ? cheerz

    .block-editor-block-list__layout .wp-block {
    margin:0px;
    }

    .wp-block {
    max-width:100%;
    }

    1. Gav says:

      Sure, if you want a standard wp-block layout to span 100% of the available width with no margin to seperate the blocks.

  2. Inez Aponte says:

    Hi Gav,

    I just downloaded your plugin but the block editor is still narrow. Is there something else I need to do?

    Thanks,Inez

    1. Gav says:

      Hi

      Don’t use the default values from the post, adjust them to suit your needs. Try changing the values to ‘none’ instead 🙂

  3. Brittney says:

    Where does the “add_action” go?

    1. Osman says:

      It goes in the same function.php.

  4. Caco Martin says:

    Thanks for share!

  5. Sagive says:

    Why aren’t u using percentages? Any particular reason or these are just for example?

    1. Tud says:

      I think is just an example. He mentioned above this:

      Gav
      23rd November 2020 at 12:50 am
      Hi

      Don’t use the default values from the post, adjust them to suit your needs. Try changing the values to ‘none’ instead

  6. Caco Martín says:

    Thank you! Now the typing experience is more enjoyable.

Join the discussion!

You might like:

Create, register and use shortcodes in WordPress

Create, register and use shortcodes in WordPress

by Gav 18/03/2023

Learn how to create and register your own WordPress shortcodes to add dynamic content to your posts and pages.

How to use guard clauses in JavaScript

How to/why use guard clauses in JavaScript

by Gav 16/03/2023

Learn how to improve code readability and performance by using guard clauses in JavaScript. Discover their benefits and best practices.

Implements and Extends, Object Oriented TypeScript

Implements and Extends, Object Oriented TypeScript

by Gav 15/03/2023

Learn the difference between implements and extends in TypeScript. Use Implements to implement interfaces and types, and extends to inherit from classes.

Reading/Parsing and Writing YAML files in PHP, Symfony

Reading/Parsing and Writing YAML files, PHP Symfony

by Gav 14/03/2023

In this tutorial we will look at using YAML in PHP. Learn about Parsing and Writing YAML files using Symfony's YAML component.

Measuring code execution performance in JavaScript

Measuring code execution performance in JavaScript

by Gav 13/03/2023

Measuring code execution performance is an important way to identify bottlenecks. Use these methods in JavaScript to help optimise your code.

Measuring script/code execution time in PHP using microtime

Measuring script/code execution time in PHP, microtime

by Gav 06/03/2023

Find bottlenecks, optimise and clean your code, and speed up your apps by measuring the execution time of your PHP scripts using microtime.

Regenerate WordPress media image sizes, programmatically

Regenerate WordPress media image sizes, programmatically

by Gav 25/02/2021

Learn how to regenerate and update WordPress media and image sizes both programmatically (without plugin), and also with a handy plugin.

Magic Constants in PHP. What they are and how to use them.

Magic Constants in PHP. What they are and how to use them

by Gav 15/02/2021

Ever seen constants like __DIR__ and __FILE__ being used in PHP? These are 'Magic Constants', and this is how we can use them.

Detecting Keypress JavaScript

Detect single and multiple keypress events: JavaScript

by Gav 16/10/2019

Learn how to use event listeners to detect and handle single and multiple keypress events in JavaScript. Add modifier keys to your application!