How to render specific form elements from the *.theme file I am using Drupal 8 and would like to customize how form elements are being displayed. Specifically, I don't like how uneditable, populated textfields are displayed as plain text. I would have it being displayed as an editable textfield (or have the text look like it is in an uneditable textfield). I have looked at various hook functions to try and achieve this but nothing seems to work. 

I figure the best way to go about this is if I can render the form fields individually myself and then create a twig file that displays the individual fields as I would like them to be displayed. Here is what I would like the twig field to look like:

&lt;div class="from"&gt;
  {{ form.mail }}
&lt;/div&gt;

&lt;div class="message"&gt;
  {{ form.message }}
&lt;/div&gt;

&lt;div class="actions"&gt;
  {{ form.actions }}
&lt;/div&gt;


This is what I came up with so far:

function theme_preprocess_form(&amp;$variables) {

  $elements = $variables['element'];
  foreach($elements as $key =&gt; $element) {
    if (substr( $key, 0, 1 ) !== "#" ) {
      // $variables['form'][$key] = render[$element];
      // This is where I need the code to actually render the element
    }
  }


}

What is the function I need to call to return a fully rendered form element?

To clarify, I would like to accomplish this by only using they my_theme.theme file for my_theme. 

Thanks.
The base hook form from the question is for rendering the HTML form tag. To render single form elements you need to specify a separate custom template.

1. Register the custom template in a theme hook

mytheme.theme or mymodule.module:

/**
 * Implements hook_theme().
 */
function mytheme/mymodule_theme() {
  return ['entity_moderation_form' =&gt; ['render element' =&gt; 'form']];
}


2. Add the custom template to the form

While building the form

EntityModerationForm::buildForm():

  public function buildForm(array $form, FormStateInterface $form_state, ContentEntityInterface $entity = NULL) {
    ...
    $form['#theme'] = ['entity_moderation_form'];
    return $form;
  }


or to an existing form in a form alter hook:

mytheme.theme or mymodule.module:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mytheme/mymodule_form_FORM_ID_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['#theme'] = ['entity_moderation_form'];  
}


You can skip this step if you use as template name the form id, see the comment from @BradJ.

3. Use the custom template to style single form elements

entity-moderation-form.html.twig:

{{ attach_library('content_moderation/content_moderation') }}
&lt;ul class="entity-moderation-form"&gt;
  &lt;li&gt;{{ form.current }}&lt;/li&gt;
  &lt;li&gt;{{ form.new_state }}&lt;/li&gt;
  &lt;li&gt;{{ form.revision_log }}&lt;/li&gt;
  &lt;li&gt;{{ form.submit }}&lt;/li&gt;
&lt;/ul&gt;
{{ form|without('current', 'new_state', 'revision_log', 'submit') }}


The example is from the core module Content Moderation.