Support » Developing with WordPress » Extending Gutenberg’s link options(toggle class)

  • Links in Gutenberg have a toggle for “Open in new tab”. Preferably I would add an extra toggle below this one with, for basic example, “Style as button” which just sets a class or custom attribute that I require.
    Problem is, I have no clue where to start. I can’t find related hooks or ways to extend this feature. It makes sense if it’s possible but the documentation is just too vast.

    Alternatively it’s also acceptable if the toggle sits next to make a link in the toolbar. But the button should only be enabled for anchors, but whenever I try to only target anchors the original Link button gets removed.

    Any idea where to start or maybe someone has already created something similar?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @renegeuze

    There’s a block named “Button” in Gutenberg that you can make use of. You can have additional CSS classes to it as well.

    Here’s a small screencast on how you can achieve this:

    Hope this helps 🙂

    Thanks for your answer, unfortunately I need it for inline anchors(and I have some other use cases too).
    Using it for button styles was just an example. And letting editors fiddle with classes is a no go as well.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Extending Gutenberg’s link options(toggle class)’ is closed to new replies.