RichText Editor core/underline missing
Description
<RichText /> should allow underlining text.
There is code for it in this repo https://github.com/WordPress/gutenberg/tree/trunk/packages/format-library/src/underline.
But it does not show up as option
Step-by-step reproduction instructions
npx @wordpress/create-block starter-blockcd starter-blockwp-env startnpm start- Add the RichText editor to the edit.js
import { RichText } from "@wordpress/block-editor";
<RichText
tagName="div"
value={attributes.test}
onChange={(test) => setAttributes({ test })}
/>
- see no underline
Screenshots, screen recording, code snippet

Workaround:
/*
Register underline button to rich text editor
https://developer.wordpress.org/block-editor/how-to-guides/format-api/
*/
const UnderlineButton = ({ isActive, onChange, value }) => {
return (
<RichTextToolbarButton
icon="editor-underline"
title="Unterstrichen"
onClick={() => {
onChange(
toggleFormat(value, {
type: "my-project/underline",
})
);
}}
isActive={isActive}
/>
);
};
registerFormatType("my-project/underline", {
title: "Unterstrichen",
tagName: "u",
className: null,
edit: UnderlineButton,
});
Environment info
- Wordpress 6.1.1
"@wordpress/scripts": "^25.2.0"- Chromium and Firefox on Linux
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Hi @aceArt-GmbH, The underline can be run from the shortcut, but as far as I know, it is intentional that it is not shown in the dropdown. The following topics will give you some background information.
- #43616
- #7162
- #13117
okay, if this is intentional it should at least be documented somewhere in the RichText documentation with a way to re-enable it if someone wants it. Or if you can not re-enable it, feel free to include my workaround
The first underline button was removed in WordPress 4.7, before Gutenberg was introduced.
This article states that it was removed due to accessibility issues. I think it would be inappropriate to dare to document how to enable this. If there are developers who want to enable this, I think they can implement it with reference to Formatting Toolbar API.
@ellatrix I would love to hear any feedback on documenting how to re-enable the underline button.
Just checking in on this issue - to see if there's anything we need to discuss/decide and action - or if it can be closed?
@jordesign Thanks for digging up this issue.
As I have commented several times on this issue, I believe the removal of the core/underline shortcut button was not appropriate from an accessibility standpoint and was removed after discussion and consensus.
Developers who really want to add that button could look at the Formatting Toolbar API documentation and implement it, and I don't think we should put a deprecated method on the site.
@aceArt-GmbH
I would like to close this issue, but if you have any suggestions feel free to comment.