Theming a table '#type' vs '#theme' I am dynamically rendering a table in a Drupal 8 module. While creating my renderable array I noticed that I can define my table as a '#theme' =&gt; 'table' or as '#type' =&gt; 'table'.

$variables['test_table'] = [
    '#theme' =&gt; 'table',
    '#header' =&gt; $header,
    '#rows' =&gt; $rows,
    '#attributes' =&gt; array('class'=&gt;array('my-table')),
    '#header_columns' =&gt; 4,
];


vs:

$variables['test_table'] = [
    '#type' =&gt; 'table',
    '#header' =&gt; $header,
    '#rows' =&gt; $rows,
    '#attributes' =&gt; array('class'=&gt;array('my-table')),
    '#header_columns' =&gt; 4,
];


Both of these options seem to output the same thing.

My question is this: Why can I use either '#theme' =&gt; 'table' or '#type' =&gt; 'table' when defining a table renderable array and is there any difference between how Drupal will render these differently.
I believe ultimately both will do the same thing. But when you use 'type' you are referring to what drupal element to use (see https://api.drupal.org/api/drupal/elements) and when you use '#theme' you're directly telling it what twig template to use.