Drupal 8: Read field value from $variables in preprocess_html
So your field is on the node?

Then you need to get the node object first.

&lt;?php
if (($node = \Drupal::routeMatch()-&gt;getParameter('node')) &amp;&amp; $node instanceof \Drupal\node\NodeInterface) {

}


Once you have that, you can read your field, assuming it is a text field, like this: $node-&gt;field_background_color-&gt;value. Make sure to always check if you really have a $node object as done in the snippet above when you're in the global context. You will only have on on node/N, but not on other pages.

There are many questions already about how to access field values, and there are great presentations as well.