How to add class in current page link fields? I have an unlimited number of button who are link fields. Like on photo down.
{{ loop.first ? field.element_attributes.addClass(green) }}

I use this in twig to add class green for first button.
Orange button is link of current page where I am. How to add orange class to that field in loop?

There is loop.first, loop.last, loop.index, loop.index0, loop.lenght..Is someone for current page?
If the links are not part of the menu tree, then this can be tricky. Essentially you'll have to evaluate the href value to the current URL.

Otherwise, if they were part of the menu, you can look to the default menu.html.twig file and see in its items loop:

// code ...
{% 
  set classes = [
    item.in_active_trail ? 'active-trail'
  }
%}


As it stands in your situation, you may want to do this in a preprocess and not the twig file itself.

function mytheme_preprocess_field(&amp;$variables) {
  // code ..
  $url = Url::fromRoute('&lt;current&gt;');

  // loop field values, compare $url to value
  // if match, add 'orange' to class in the attributes
}


Then you would only have to worry about rendering the link fields in the twig, as the attributes part will take care of getting the class to the output.

I suppose another way of encapsulating this logic would be writing your own field formatter for this purpose.