-
Notifications
You must be signed in to change notification settings - Fork 65
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
Anchor with Button styles #430
Comments
Hey @hobadams, Thanks for submitting this issue! Before I get into the weeds of the root issue, I'd like to point out that we do have the ability to use Okay, so down to using Buttons are traditionally used to express actions, things that users interact with on the current page. While anchors are used for navigating to different pages. Take text context out of the equation, but when you use a link that looks like a button it tricks a user that they are going to interact with something on a page instead of navigating. The same is true about the inverse - treating an anchor like button. Also, TypeScript cannot handle dynamic props like this. Say we use IMO I am against doing this. It should be on the designers to use the appropriate components and on the developers to safe-guard this notion. |
Hey @chanceaclark thanks for your response I appreciate the detailed feedback. I still feel like it's quite a common requirement to have anchors that have the look of buttons. I agree with some of your points about accessibility but feel that if the content / title / aria-label of the anchor or button is descriptive enough then it's not a huge issue. I also appreciate that dynamic props would cause an issue. Perhaps my request makes more sense out of the context of a BigCommerce app. What are your thoughts on adding some of the styles to css classes? |
I have to respectfully disagree with this. I encourage you to read about the first and second rule of ARIA: I also encourage you to read this article on why it's such a bad practice in the first place: If you need a button to behave like a link, wrap a button in an anchor and disable the tabindex on the button. There are specific behaviors each of the elements outlined in the above article that is intended for each element. <a href="#">
<button tabindex="-1">Learn More</button>
</a>
IMO this is more of a fundamental HTML/CSS/A11y issue more than in-or-out of the BigCommerce app context.
BigDesign is not a CSS library, at least in this stage of the library. One of the main goals of the library is to allow apps and app developers make their apps and integrations look and feel like it was apart of the BigCommerce ecosystem. That being said, we have tailored this React library to lock stylings so that developers don't stray from uniform design patterns. As of this stage of the library, we are against adding any CSS classes until we have further discussions around if/how to support it. |
I'm not sure we should wrap https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element
|
Thanks @leeBigCommerce . That wasn't the intention. It was to allow anchor tags to inherit the core button styles. The use case would be if you wanted to have a big button that linked to your docs or some other url. This SHOULD be an anchor but you may want it to look like a button. |
@leeBigCommerce apologies, just saw the comment above and now know why you said this! I agree with you, a button inside an anchor is a no go. |
Been thinking about this for a bit now... I'm starting to see the other side of this argument. I'm still debating in my mind the user-experience aspect of it, but for the DX part of it should be fairly simple to implement (to put it simply, a button with an |
@chanceaclark it's a fairly common design pattern, whether it's correct usage or not, and I'd say people are pretty used to it by now. I doubt you'll confuse anyone as long as the HTML is semantically correct and proper aria labels are applied. If you only enable it by adding a For example, other component libraries, such as Chakra UI, allow you to pass an I'm not a TypeScript ninja, and I never use strict, so I can't say its implications on TS. I don't get IntelliSense that |
Hey all, I threw up a draft PR regarding this #663. Still having some type issues but I'll get back to this in the new year. |
Is your feature request related to a problem? Please describe.
I would like to add an anchor tag that has the styles of the
<Button>
components.Describe the solution, feature, or improvement you'd like
I think the easiest solution would be for the
<Button>
component to accept anas
prop. We can then pass<Button as="a">
.In my opinion this would be a great option for all of the components. It would mean you could use
<Box as="section">
etc.Apologies if this is already possible, I couldn't see it in the docs.
Describe alternatives you've considered
An alternative is to have all the button styles available to css classes. This seems quite bloated though
Additional context
N/A
The text was updated successfully, but these errors were encountered: