Drupal 8 Webform Composite fieldset
Place the fields inside of the fieldset:

$elements['grouped_fields']['field1'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Field 1'),
];
$elements['grouped_fields']['field2'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Field 2'),
];
// ...