-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Support "unstyled" usage #67320
Comments
A useful exercise could be to run through Also, we may want to "merge" the |
I’d like to implement this enhancement but wanted to discuss the approach first. To keep the code DRY, I propose extracting base button styles into reusable mixins (focus, active, disabled, etc.) and applying them under The For example: gutenberg/packages/components/src/button/style.scss Lines 41 to 46 in 8783607
Extracting the above styles into a mixin ( What do you think of this approach? I’d appreciate any guidance or suggestions for improvement. |
Hey @yogeshbhutkar, thank you for the comment! I'm not exactly sure what @mirka had in mind when proposing a Probably better to wait for @mirka 's feedback before moving forward, also considering that an alternative to the approach was to provide an |
Thanks for the reply, @ciampo.
The issue with an unstyled variant is that a developer may only need to override layout styles like height while keeping the existing focus, hover, and other interactive styles. Exposing these styles via a hook allows them to be easily retrieved and applied as class names. Otherwise, important accessibility considerations might need to be made consciously. I’m thinking const { ...defaults } = useButtonStyles();
// To apply only the focus styles.
const { focusStyle } = useButtonStyles(); Essentially, Edit: |
What problem does this address?
There have been cases where the
Button
component is used with heavy style overrides. This can lead to subtle bugs and breakages down the line.Although we should always first reconsider if one of the standard Button style variants can be used instead, in some cases heavy style customization is warranted. While styling a simple
button
element from scratch may seem like a valid alternative, that may also lead to developers overlooking subtle considerations (focus styles, accessibility, etc) that are already handled inButton
.What is your proposed solution?
We should audit the repo for the kinds of valid style overrides we have, and figure out how Button can support those use cases cleanly. Some possibilities include:
unstyled
variantuseButtonStyles
hookThe text was updated successfully, but these errors were encountered: