Creating a table with pagination in a Node Edit form
You can use tableselect instead of details something like:

   $query = \Drupal::database()-&gt;select('node', 'n')
      -&gt;condition('type', 'article', '=');
    $query-&gt;fields('n', ['nid']);
    $query-&gt;innerJoin('node__field_articles_category', 'category', 'category.field_articles_category_target_id = ' . $categoryId);
    //For the pagination we need to extend the pagerselectextender and
    //limit in the query
    $pager = $query-&gt;extend('Drupal\Core\Database\Query\PagerSelectExtender')
      -&gt;limit($limit);
    $article_ids = $pager-&gt;execute()-&gt;fetchAll(\PDO::FETCH_OBJ);
    $rows = [];
    foreach ($article_ids as $index =&gt; $article_id) {
      $article = Node::load($article_id-&gt;nid);
      $rows[$index + 1] = [
        'title' =&gt; $article-&gt;getTitle(),
        'url'   =&gt; Drupal::l($article-&gt;getTitle(), $article-&gt;toUrl()),
      ];
    }

    $form['related_articles']['table'] = [
      '#type'    =&gt; 'tableselect',
      '#header'  =&gt; ['title' =&gt; t('title'), 'url' =&gt; t('Url')],
      '#options' =&gt; $rows,
      '#empty'   =&gt; t('No users found'),
    ];
    // Finally add the pager.
    $form['related_articles']['pager'] = array(
      '#type' =&gt; 'pager',
    );


Result will be like: