Skip to content

Global Styles: Elements: Captions text color not respected in front end. #42054

@scruffian

Description

@scruffian

Description

When I try to set the caption text color, the CSS overwrites it, when a theme opts in to opinionated styles.

This happens when theme opt in to opinionated CSS, using the wp-block-styles theme support:
add_theme_support( 'wp-block-styles' );

To solve this we should move this CSS into the block.json file so that the user settings override it. However this is complex because the CSS comes from the theme.css file, not the standard block file. We might need to introduce a new key to block.json for opinionated block styles.

cc @adamziel @draganescu @getdave

Step-by-step reproduction instructions

  1. Switch to empty theme
  2. Add this to the theme.json under elements. Note that the text should be white:
			"caption": {
				"border": {
					"color": "grey",
					"radius": "10px",
					"width": "5px",
					"style": "solid"
				},
				"color": {
					"background": "limegreen",
					"text": "white"
				},
				"spacing": {
					"padding": "10px"
				},
				"typography": {
					"fontFamily": "sans-serif",
					"fontSize": "20px"
				}
			},
  1. Add a table block with a caption.
  2. Notice that in the front end the color of the text on captions is still grey

Screenshots, screen recording, code snippet

Screenshot 2022-06-29 at 16 46 11

Environment info

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions