How do I create a simple table? I am working on a module where I need to display content in a table. Though I have created a simple table already, I need to know how to use theme(), as the function cannot be called directly.

Basically, What is the equivalent of the following line, which was perfectly fine in Drupal 7?

return theme(table,array(header =&gt; '$header', rows =&gt; '$rows'));
As reported in New render element #type 'table' and theme() renamed to _theme() and should not be called directly, the equivalent of $table = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows)) for Drupal 8 is the following.

$form['table'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
];


(Replace $form with the variable containing the rendering array.)