Building option panels for plugins have never been a fun task. It is usually the thing developers do at the end, and most developers do not put much effort into designing their options panel at all. But can you make an options page with components from Gutenberg?
Previously in a two-part series, I discussed how to build blocks for Gutenberg, now known as the block editor. But the brilliance of the whole block experience does not end on the front end – with blog posts and pages.
We can also make an options page with components from Gutenberg. While it sounds complicated, it is a straightforward process that actually requires less time than the standard way of doing things.
Here’s a screenshot of Gutenberg Blocks and Template Library by Otter (our plugin) where we built an options page with components from Gutenberg:
Simple and clean, right? Here’s how to build something like this:
What are these components?
Great question! Gutenberg components are nothing but React components made with an abstraction layer that makes you feel like you are not using React. But yeah, technically it is React.
Also, we will be using JSX to write our code. If you are new to JSX, you are going to love it.
Code files + notes
? Before we go ahead, you can find all the code that we have used here in this GitHub repository. You can install the plugin to see the final product of this tutorial.
In this article, I do not use Block Editor and Gutenberg interchangeably. By Block Editor, I only refer to the editor part of Gutenberg.
Setting up a “plugin options page”
The setup for our project is straightforward. Just like the human heart, it has two parts: the options page & build files.
First, we need to register our plugin & options page as usual:
This article was written by Hardeep Asrani and originally published on CodeinWP.