How to clone any standard webform element I've been able to copy the example webform element, as detailed at Create webform element.

Although I've not tested submission yet, I think it's all looking good.

What would be great is if I could clone any of the standard webform elements.  

I've made a copy of src/WeformElement/Email.php - and it appears in the list of webform elements available to be inserted into the webform - but when viewing the actual webform, it is not rendered.

It may be that I have to use the example webform element to create a new copy, and then change stuff in there to render an email field instead, but as mentioned I'd appreciate any pointers towards being able to clone any of the elements.

(The reason we need to clone them is due to styling. One text field might be used for a name, and another for a completely different purpose which will be styled differently, and as the cloned element has a new id then we can use the module Themable forms to provide more template suggestions.)
The WebformElement plugin acts as a wrapper around a Drupal Form element plugin.  Therefore to actually create a webform element you need to define a Form element plugin with a corresponding Webform element plugin.

If you want to extend the Email element you need to extend the below classes


\Drupal\Core\Render\Element\Email
\Drupal\webform\Plugin\WebformElement\Email


All you might missing is a \Drupal\custom_module\Element\CustomModuleEmail class which probably will look something like...

&lt;?php

namespace Drupal\custom_module\Element;

use Drupal\Core\Render\Element\Email;

/**
 * @FormElement("custom_moduel_email")
 */
class CustomModuleEmail extends Email { }