Closed mcheung-nhs closed 4 years ago
What’s the rationale to use a link styled as a button and then try to semantically suggest it’s a button? Would you not just use a button?
Hey @andrewbarnesweb this would be for when semantically it should be an anchor tag, but have the styling of a button. For example on the GOVUK Start page pattern, which is commonly used within NHS services (although not in our service manual just yet). Buttons are used more for a form when submitting and can't be used as links to another page.
Hey @andrewbarnesweb this would be for when semantically it should be an anchor tag, but have the styling of a button
If semantically it should be an anchor tag, then it should be a standard link? Whether it's styled to look like a button is just how it looks, not connected to accessibility and semantics. So I don't think it makes sense to have role="button"
on an anchor tag.
role="button"
in my opinion is more for if you ever wanted to use other element types to behave like a button, e.g if you had a div
that was supposed to toggle something on the page. Although, wherever possible, just use buttons and style them because then you obviously get all the good stuff for free 🙂
I second that this doesn't seem like something we should be doing... I understand that maybe it feels like the "Start page" is a button but semantically it is not and doesn't give any accessibility benefit to making it behave like button either, in fact I think it is more confusing.
Going to close this issue following discussions above!
When using the button component as a link, you need to be able to trigger the link via the spacebar, which is what you can do with a real button but not with a link.
Because the link has a role of
button
then assistive technologies (screen readers, dictation software) will describe it as a button so users will expect to be able to trigger it using the spacebar.See here for example of code that can be used:
https://github.com/alphagov/govuk-frontend/blob/master/src/components/button/button.js#L19-L34