-
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
Button block default styles not applied to manually added buttons #41824
Comments
Hi @bradley2083, thanks for the report. What theme are you using? With Twenty Twenty-Two, adding your code via the Custom HTML widget pretty well replicated the button style for the Search and Post Comment buttons, though there is a tiny grey border that shouldn't be there. (I also tried adding the class Could you please share what theme you're using, as well a screenshot of what you're seeing, showing both an existing button and the button from your custom HTML block? |
Hey, @kathrynwp. The reason you're almost seeing the right default button style is because a button already exists on that page (in the comments form). I'm testing in a local environment with no plugins (other than Gutenberg) and the default 2022 theme. To replicate, create a page with comments disabled and add both of the following:
And you'll see both look like this: |
@bradley2083 Gotcha, thanks for the steps to replicate. My inclination would be to say that's not up to Gutenberg to automatically add styling to arbitrary elements in custom HTML blocks, which seems to be confirmed by @carolinan's comment here: I've pinged Carolina in case they are able to chime in with a second opinion here. |
@kathrynwp I think at the very least the default button styles set in theme.json should be applied to a button, no? Even if you add something like this using the Custom HTML block the default theme.json button styles don't work:
Because the button styles are applied inline. |
I understand what you're saying, but I'm thinking that this may be the case because the relevant button CSS is only loaded if a button block is loaded on the page (rather than recreating one with custom HTML) but Carolina can probably shed some light. |
@kathrynwp Unable to comment on that thread with @carolinan but her last comment mentions how WooCommerce styles forms / buttons using but you need to use the CSS classes, but this is not longer the case in WooCommerce. If you test with Woo and create a blank page with no other buttons and insert their "Hand-picked products" block, you'll see the styles from are somehow applied inline with the appropriate CSS classes (and I assume somehow are pulling in the styles set for the button block in the theme's theme.json. or global styles if the button style has been overridden - at least that's what should happen). Let me know what you think. |
It depends.
|
@carolinan Do you have a reference to how we'll be able to style |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
I am going to close this issue as the original report was based on an incorrect expectation about how custom HTML should be styled. Thanks again for the report @bradley2083 and please feel free to reopen this, if necessary. |
@mrfoxtalbot I'm reopening because I don't see why there shouldn't be a way to apply the core button block style to anything that uses |
Thank you for your reply @bradley2083. I was looking at it from a "this is not a bug per se" perspective but I have reopened the issue and labeled this as "Enhancement". |
@mrfoxtalbot Thank you! |
@bradley2083 I would like to understand where you are seeing |
@carolinan this comment explains how to replicate |
@bradley2083 But the example theme does not support the feature. |
Twenty Twenty-Two was built before button elements were supported in theme.json. |
@carolinan To replicate:
|
And if you include the expected CSS class wp-element-button? |
Hey, @carolinan. If I add
The buttons do not pull in the default styles of the core button block set in the theme.json. When you say "update theme.json", do you have an example of that? I believe any environment / theme I've tested has an updated theme.json but would love to rule that out as an issue just not seeing any docs on actually "updating theme.json". Thanks! |
I don't think that elements inside the html block are rendered as blocks, I am sceptical to that working, it needs to be tested. I don't think these classes will be detected and the styles loaded. With updating theme.json I mean adding styles to |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
@carolinan I don't believe even the comment form button takes on all of the default theme styles from the theme's theme.json for a button, right? Adding the ability for any button or input that has |
The default themes support different versions of WordPress, so you will get different results. |
@carolinan I think this is actually working with the latest options for theme.json. I was putting the theme button styles in styles > blocks > core/button rather than styles > elements > button. Looking through the Twenty Twenty Three theme was helpful. Thanks! |
Hi there, |
@eZoulou Hi! Kindly use the WordPress support forum for support. When you render block markup with PHP, you need to do it correctly before |
Hi @carolinan. |
Description
If you create a new page, add an HTML block that let's say includes a simple form code like:
<form><input type="email" placeholder="your@email" value="" name="EMAIL" class="required email" aria-required="true"><input class="wp-block-button__link" type="submit" value="Subscribe →" name="subscribe"></form>
The input button does not use the default button block styles.
Step-by-step reproduction instructions
<form><input type="email" placeholder="your@email" value="" name="EMAIL" class="required email" aria-required="true"><input class="wp-block-button__link" type="submit" value="Subscribe →" name="subscribe"></form>
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: