I am working on a custom block for Gutenberg and part of this block is a RichText component. I am trying to add a button that underlines the text and I cannot make it work since last night. The code I have now [does not work]:

                controls={ [
                        icon: 'editor-underline',
                        title: __( 'Underline' ),
                        onClick: () => {
                          console.log(this.test.current, this)
                                { type: 'core/underline' }
                            ) );
                ] }
                  className={ className }
                  value={ content }
                  onChange={ ( content ) => { this.props.setAttributes( { content } ) } }

Can you help me on working this thing out?

  • toggleFormat is from import { toggleFormat } from '@wordpress/rich-text';
    – Filip
    Jul 3, 2019 at 9:09

1 Answer 1


In a block that I am currently trying to build I am using a RichText control.

This has buttons/menu items for Bold, Italic, Code, Link, Inline Image and Strike though.

Though there isn't a button for underlining the text I can just use the key command [cmd+U] and it underlines.

This seems to work and is saved on the frontend and backend.

If it was working. There could be a few issues why it has stopped. Have you any errors in the console?

Have you tried removing the block and re-adding it?

EDIT: I am a beginner with Gutenberg block development so I am out of my depth!

You might find this useful if you haven't already come across it.

Add Formatting Buttons to Gutenberg core/paragraph BlockControls

  • cmd+u works, but the client wants a button
    – Filip
    Jul 3, 2019 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.