Sub-menu items in twig
menu_links is a Twig macro, that is called recursively. That macro is located in menu.html.twig. In there you can do stuff based on current menu_level. 

{% if menu_level == 0 %}
  &lt;ul class="menu--main"&gt;
{% else %}
  &lt;ul class="menu--sub"&gt;
{% endif %}


Notice that this macro is called recursivly, so if you are adding a classes like {% set attributes = attributes.addClass('menu--level' ~ menu_level) %}, this additional class is also stored and passed down recursivly!

Also take a look at core/themes/classy/templates/navigation/menu.html.twig to get an example of a full menu template file.