To have a variable in a field template you need a field preprocess hook:
use Drupal\paragraphs\ParagraphInterface; function mysubtheme_preprocess_field(&$variables) { $paragraph = $variables['element']['#object']; if ($paragraph instanceof ParagraphInterface) { if ($paragraph->getType() === 'sidebar_button_repeater') { if (!$paragraph->field_background_color->isEmpty()) { $variables['color'] = $paragraph->get('field_background_color')->value; } } } } If the field is in the parent paragraph of a nested paragraph:
$parent = $paragraph->getParentEntity(); And get the field value from $parent:
function mysubtheme_preprocess_field(&$variables) { $paragraph = $variables['element']['#object']; if ($paragraph instanceof ParagraphInterface) { if ($paragraph->getType() === 'child_type') { $parent = $paragraph->getParentEntity(); if ($parent instanceof ParagraphInterface) { if ($parent->getType() === 'parent_type') { if (!$parent->field_background_color->isEmpty()) { $variables['color'] = $parent->get('field_background_color')->value; } } } } } }