How to add class to the options for type radio present under radios? function template_preprocess_bef_radios(&amp;$variables) {
  $variables['children'] = Element::children($variables['element']);
  _bef_preprocess_nested_elements($variables);
    foreach($variables['element'] as $tid =&gt; $value) {
        if (is_numeric($tid) || $tid === 'All') {
            $value['#attributes']['class'][] = Html::cleanCssIdentifier($value['#title']);
        }
    }
 }


While trying the above does not add class to radio button under radios(which has multiple options)
How can I add class to the options ?
You are almost there just you should change $variables['element'][$tid]['#attributes']['class'] instead of $value['#attributes']['class'] try with:

/**
 * Implements hook_preprocess_HOOK().
 */
function template_preprocess_bef_radios(&amp;$variables) {
  // No need to this two lines 
//  $variables['children'] = Element::children($variables['element']);
//  _bef_preprocess_nested_elements($variables);
  foreach($variables['element'] as $tid =&gt; $value) {
    if (is_numeric($tid) || $tid === 'All') {
      $variables['element'][$tid]['#attributes']['class'][] = Html::cleanCssIdentifier($value['#title']);
    }
  }
}