-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert Link: consider adding an "Additional CSS Class" field to the link inserter #13368
Comments
Thanks for opening the issue, Noting that it's already possible to add a className from the HTML mode to links. and it's also possible to replace the link format with a custom link format with this feature. The UI doesn't support it though. |
Hi there! |
The design team discussed this during a triage session in Slack today (Note: You may need a Slack account to log in.) The overall consensus was that we're not sure this is a common enough use case to warrant introducing additional complexity to the interface. WordPress' philosophy is to "provide features that 80% or more of end users will actually appreciate and use", and we're not certain if this is a common enough action that 80% of users will use it. Let's establish a user need for the functionality, and then, if we think it's warranted and necessary, we can explore options for implementation. The mockup here may prove confusing for users, since it adds a control for an inline element to its parent element, which runs counter to our pattern of only placing controls for the currently-selected element in the sidebar. If we decide this is a useful enough feature to add to the core software, it would be good to explore other potential placements. |
ok based on these discussions, I'm going to close this issue for now now. Thanks all. |
@sarahmonster fair comment there. there is ofcourse the workaround to set this in the HTML view. I'm a technie myself, but the new editor is such a delight and i get most work done front-end and i don't want to be fiddling with code. As a blogger, my use case is while I'd like to link to several pages from a post, I would like to highlight a couple of links on the post where i'd like to draw user attention. you can see an example here where the mentoring sessions & decision framework links are highlighted: http://www.prasadgupte.com/blog/5-tips-how-to-find-expat-job-in-germany-eu/ thanks! |
No it doesn't. It adds a control for the inline element just to the inline element, in exactly the same way that you have provided other controls for the inline element (specifically, the ability to add target="_blank"). I've been using the workaround of editing in HTML mode and adding a class, but have now just discovered that if you then go back to Visual editing and click the 'Open in new tab' toggle, the custom class gets deleted. So if you're suggesting the HTML mode is a valid workaround, the rest of the inline controls are broken. |
Yep. If you decide to update link via UI, custom classes are removed. HTML mode isn't a solution at all. |
this is a common use case, we need this. html mode is not the answer because the editors should not have to use it. furthermore the class is removed when you change the link. often a link has maybe an icon and you can't alway use a button. for example inline links. please do the little effort for an big impact ;-) |
This is a real issue. Easy example is putting in text-decoration-none when using a bootstrap 5 theme. That has to be a link class. |
Upvote. This needs to be a feature. |
I'm building a press page for a client, which he should then be able to keep populating oh his own of course. |
Mandatory feature. Absolute silliness to suggest that it won't be used. There is no workaround except using an entirely custom HTML block. You can't even edit the HTML because it immediately removes the class as soon as you save. This bug is absolutely needed to be fixed. |
+1 for this feature, really a must! |
+1 ... The classes field was a Screen Option in the previous editor. Very useful for adding the "smooth-scroll" class to the anchor link where it's needed... not the block. This is a feature removal that should be reconsidered. |
This came up as I was working on adding glightbox to a test site. For creating a tutorial on how to add a lightbox to Gutenberg. I was told this: Related to this comment: #13368 (comment) |
@paaljoachim interesting idea and use case this one. From reading the background in the discussion here, it sounds like it's a needed feature for a bunch of people, but that the problem of how to make it usable / discoverable without interfering with the regular UX of editing content hasn't been solved from a design angle. At the block level, the Advanced panel is nicely tucked away so that it's unobtrusive for regular usage. But I can see the point that exposing the ability to add a class name within the popover when editing a link won't be used by most folks in the regular task of writing content. Since this issue is fairly old now, if folks feel strongly about adding in the feature, it might be worth opening up a fresh issue with an example use case and idea of how it should work, and then attach some design labels to gather more feedback? |
That part is trivial as I mentioned back in 2020. When you click the link icon, you see three toggles for controlling the link (open in new tab, nofollow, sponsored). All you need is a 4th option where you type in a class. Done. Edit - sorry, I see you thought possibly this shouldn't be done because most people won't use it. To be honest, I've never used the 'sponsored' toggle, and it doesn't cause me any problems that I see it. |
I only see
I don't feel strongly either way — but since this is a fairly old issue and the design team didn't think most folks would use it back in 2019 (I'm not a designer 😄), I thought a good way to get some buy-in from folks would be for anyone who wants to see this feature land to write up a fresh issue for it, outlining how it should ideally work. The interactions on some these components can get really fiddly, so it could probably use a designer's eye. |
You're right - the other two came from the Yoast SEO plugin. Whoops. But yes, replicating that link CSS class field would be perfect. Based on the comments above, it's true the design team didn't think most people would need it - and that's probably fair - but they also made two mistakes (thinking HTML mode was a valid workaround, which doesn't work, and thinking the mockup would be adding a control for an inline element to a parent element, which it wasn't). If there are plenty of valid use cases, no single possible workaround, and there already exists a similar feature, then it seems worth it. |
@paaljoachim in the case of adding classes to an image anchor tag you can do this in the UI as Andrew shows above: So no need to edit the html manually. In the case of the Image block, the blocks custom classes have to be applied to the Also, in the case of glightbox you can specify a custom selector, eg. |
A new issue was opened up here recently about classes and links - #38878. |
This is clearly something that we need to consider adding. It would be great if we could open a new Issue with:
We can then keep this one closed. |
Actually we have this Link control issue: |
+1 for this feature. We try to avoid our users from editing HTML. |
@michaelsoriano, mind sharing how you leverage custom classes on links? Trying to get a feel for use-case here. |
Hi @richtabor - we have specific classes that we use for hyperlinks - not just for styles, but for "triggers" that invoke custom behaviors. For example, a hyperlink inside a paragraph that we want to trigger a modal. It would be great for users to be able to just add the class to the link, the same way they add classes to other block elements - instead of going to HTML view. |
I regularly use it to style links as buttons. |
I too style text links as buttons using a CSS classes and; Telling the client that they need to "edit html" and then "never change anything about that link or the HTML edit will be lost (why?) does not elicit confidence in the platform. |
Bringing back this issue to attention, because it is unchanged relevant!
So, dear WordPress developers, maybe you can consider extending the already existing "Advanced" link modal with classes like in image links and buttons? |
Re-opening this as it is a much requested feature. |
@richtabor I'm not sure if we discussed these types of fields previously but here is what an "Additional CSS" input looks like Any thoughts on how to improve welcomed |
Every block allows an additional css class in the extended section.
It would be great if an additional css class could be assigned to links also.
The resulting html would be:
<a **class="my-class"** href="https://www.somewhere.com/somefile.pdf" target="_blank" rel="noreferrer noopener" aria-label="manual (opens in new tab)">manual</a>
It is possible to insert a class in the HTML view.
The text was updated successfully, but these errors were encountered: