• Hi,

    I am using theme.json to define the theme color palette, like below:

    "palette": [
    					{
      					"slug": "pink",
      					"color": "#FFB6C1",
      					"name": "Pink"
      				},
      				{
      					"slug": "brown",
      					"color": "#3A3335",
      					"name": "Brown"
      				},
      				{
      					"slug": "orange",
      					"color": "#FFC133",
      					"name": "Orange"
      				},
      				{
      					"slug": "light-green",
      					"color": "#c6d8d3",
      					"name": "Light Green"
      				},
      				{
      					"slug": "red",
      					"color": "#E2574C",
      					"name": "Red"
      				},
    					{
      					"slug": "white",
      					"color": "#FFFFFF",
      					"name": "White"
      				},
    					{
      					"slug": "black",
      					"color": "#000000",
      					"name": "Black"
      				}
      			]

    I have created some custom WP blocks using a plugin. Some has the color UI for text and background. I know how to display the color slug name in php templates. I am using $block[‘textColor’] to return the selected color (slug name), but I am not sure how to display the hexcode color . Say I have selected ‘pink’ as the color for my heading text, I don’t want to display the slug name ‘pink’, but want to display the hexcode ‘#FFB6C1’, how can I do that?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom WP blocks – return the text/ background hex color’ is closed to new replies.