How to add a custom row class or ID to type table render elements I'm trying to add row ID's for a custom table I implemented via a custom module. But when I append an ID to the '#attributes' array it becomes the table ID, not the row ID. How can I define IDs for rows?

This is what I have so far:

$form['table'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; $header_table,
  '#rows' =&gt; $rows,
  '#attributes'=&gt; ['id' =&gt; 'IdforRow'],
  '#empty' =&gt; t('No Data found'),
  '#prefix' =&gt; '&lt;b&gt;Total Tenders : '.@$count.'&lt;/b&gt;&lt;br&gt;',
  '#suffix' =&gt; '',
];
Can you try code the below.

$row = array('data' =&gt; 'some data');
$rows[] = array('data' =&gt; $row, 'class' =&gt; 'some class');
);


Or maybe

$row = array('data' =&gt; 'some data');
$rows[] = array('data' =&gt; $row, 'class' =&gt; array('some class'));


Reference answer https://www.drupal.org/forum/support/post-installation/2016-04-21/add-class-in-row-with-theme-table