Add CSS class to fieldset div element without extending the template I only want to add a class to the  inside the fieldset from fieldset.html.twig. It's a bit overkill to extend the template for just to add a class.

How can I achieve this with a preprocess function?

function mytheme_preprocess_fieldset(&amp;$variables) {
// $variables['children']['attributes']['class'][] = 'mb-4';
}
Under a fieldsets 'Advanced' settings tab, you can add custom attributes to the fieldset.