What values can we use in `formattingControls` parameter in RichText component

So what is the complete list of supported values?

The list of available format types is maintained in the core/rich-text store. You can query the store by running this code in your browser’s console, which will return an array containing the format types:

wp.data.select( 'core/rich-text' ).getFormatTypes();

And as of writing, there are 10 default/core format types: bold, code, image, italic, link, strikethrough, underline, text-color, subscript, and superscript. (Note: I intentionally omitted the namespace, which is core as in core/bold.)

References: Introduction to the Format API » Register a New Format and the @wordpress/format-library package.

But formattingControls is deprecated. Use allowedFormats instead.

The formattingControls prop(erty), although still works as of writing, has long been deprecated (in August 2019), and you should now use its replacement: allowedFormats.

Both allowedFormats and formattingControls accept an array of format names, but with two differences:

  1. With formattingControls, you don’t need to specify the namespace, i.e. if the full name is core/bold, you only need to use bold.

    Secondly, custom format types are not supported — they won’t cause any error, but they won’t appear in (or be added to) the Rich Text toolbar, either.

  2. With allowedFormats, you need to specify the full format name including namespace, e.g. core/bold and core/italic.

    And that’s because allowedFormats supports custom format types. So for example, if you’ve registered the sample format here (named my-custom-format/sample-output), then you’d set the allowedFormats like so:

    allowedFormats={ [ 'core/bold', 'core/italic', 'my-custom-format/sample-output' ] }
    

tech