How to query all content type and add as checkbox for custom form? Need help on how to create a custom form that is only available for admins that will query all content types and display the options as a checkbox.

The goal is to only add certain libraries to particular content types selectively through an admin form. How would i query all content types and display them as checkboxes?

What we tried:

mymodule.module

function mymodue_preprocess_node(&amp;$variables) {
  $node = $variables['node'];
  $config = \Drupal::config('mymodule.settings');
  $enabled_content_types = !empty($config-&gt;get('enabled_content_types')) ? $config-&gt;get('enabled_content_types') : FALSE;

  // This is where we need help.
  if(in_array($enabled_content_type, $node-&gt;bundle()) {
    // perform some logic.
  }  
}


mymoduleForm.php

&lt;?php

namespace Drupal\mymodule\Form;

class mymoduleForm extends ConfigFormBase {
  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'mymodule.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'mymodule_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $types = \Drupal::entityTypeManager()
      -&gt;getStorage('node_type')
      -&gt;loadMultiple();

    foreach($types as $type) {
      $content_types[$type-&gt;id()] = $type-&gt;label();
    }

    // Need help setting this up so that the options are content types. 
    $form['enabled_content_types'] = [
      '#type' =&gt; 'checkbox',
      '#title' =&gt; 'Enabled Content Types',
      '#description' =&gt; 'Run preprocess for all enabled content types only',
      '#options' =&gt; $content_types,
    ],
  }
}
This was inspired from @leymannx comments. 

I changed the '#type' to checkboxes.

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
 $types = \Drupal::entityTypeManager()
   -&gt;getStorage('node_type')
   -&gt;loadMultiple();

 foreach($types as $type) {
   $content_types[$type-&gt;id()] = $type-&gt;label();
 }

 // Need help setting this up so that the options are content types. 
 $form['enabled_content_types'] = [
   '#type' =&gt; 'checkboxes',
   '#title' =&gt; 'Enabled Content Types',
   '#description' =&gt; 'Run preprocess for all enabled content types only',
   '#options' =&gt; $content_types,
 ],
}