How to make custom fieldset collapsed by default in Drupal 8 In Drupal 7 there was option to have fieldset collapsible or not, and to restrict default state of this form element (collapsed, or uncollapsed). Example:

$form['contact_data'] = array(
        '#title' =&gt; t("Contact data"),
        '#type' =&gt; 'fieldset',
        '#collapsible' =&gt; TRUE,
        '#collapsed' =&gt; FALSE,
);


Now, in Drupal 8 I cannot find attributtes #collapsible and #collapsed in Drupal\Core\Render\Element\Fieldset. In official documentation of Fieldset element is not mentioned any new element, which should substitute the Fieldset element.

Also there is not Form API elements overview for Drupal 8, such as for Drupal 7. You have to manually search for all Render Elements definition in code, which is more time consuming (especially when you would like to see elements overview and compare them).
All collapsible fieldsets have been replaced with HTML5 details
  elements.


Fieldset and legand are very hard to style and its not recommended to use with Drupal 8 any more. Instead its replaced with more cross browser way, which is the HTML5 Details &amp; Summary tags.

'#type' =&gt; 'details'


https://www.drupal.org/node/1852020

Drupal 7

$form['advanced'] = array(
  '#type' =&gt; 'fieldset',
  '#title' =&gt; t('Advanced settings'),
  '#collapsible' =&gt; TRUE,
  '#collapsed' =&gt; FALSE,
  '#description' =&gt; t('Lorem ipsum.'),
);


Drupal 8

$form['advanced'] = array(
  '#type' =&gt; 'details',
  '#title' =&gt; t('Advanced settings'),
  '#description' =&gt; t('Lorem ipsum.'),
  '#open' =&gt; TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE.
);