Skip to content
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

Button: Extract isPressed to a separate component? #45388

Open
mirka opened this issue Oct 28, 2022 · 2 comments
Open

Button: Extract isPressed to a separate component? #45388

mirka opened this issue Oct 28, 2022 · 2 comments
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Comments

@mirka
Copy link
Member

mirka commented Oct 28, 2022

What problem does this address?

As noted in #44427 (comment), the isPressed prop does not make sense in combination with certain variants or props, for example isDestructive or link.

The isPressed prop implies that the button represents an on/off toggle, which is distinct from usages where the button is purely for triggering actions.

Having nonsensical state combinations makes it harder to maintain the CSS, because it increases the number of cases that we have to deal with, even though they should never be used.

What is your proposed solution?

Create a new component (ButtonToggle?) that is a thin facade wrapper around Button. Remove all the props that don't make sense in this use case. Deprecate the isPressed prop and encourage devs to use ButtonToggle.

@mirka mirka added the [Package] Components /packages/components label Oct 28, 2022
@ciampo
Copy link
Contributor

ciampo commented Oct 31, 2022

I think this would be a good idea — I'm just unsure about how much clean-up we'll be able to do in Button, in case we can't remove the isPressed prop and the functionality that it brings

@mirka
Copy link
Member Author

mirka commented Oct 31, 2022

We definitely cannot remove it! Just a deprecation. I think the main benefit of this move is that we can relieve ourselves of the responsibility to fix/maintain the nonsensical state combos that people are likely not using at all.

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants