Skip to content

[Feature request] We need a new component <Table.HeadRow> #1467

Open
@raky291

Description

@raky291
  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

Hi, I'm trying to implement the @tanstack/react-table library with the Table component, but the tr in the <Table.Head> component is not accessible, and is hardcoded inside the component. Can make a new component for that element please? Regards.

https://github.com/themesberg/flowbite-react/blob/main/packages/ui/src/components/Table/TableHead.tsx#L29

Here is an example and the link to the library
https://tanstack.com/table/latest/docs/introduction

export default function Table<T>({ data, columns }: TableProps<T>) {
  const table = useReactTable({
    data,
    columns,
    getCoreRowModel: getCoreRowModel(),
  });

  return (
    <table>
      <thead>
        {table.getHeaderGroups().map((headerGroup) => (
          <tr key={headerGroup.id}> {/* Here, I want to have access to the tr so I can make header groups */}
            {headerGroup.headers.map((header) => (
              <th key={header.id}>
                {flexRender(
                  header.column.columnDef.header,
                  header.getContext()
                )}
              </th>
            ))}
          </tr>
        ))}
      </thead>
      <tbody>
        {table.getRowModel().rows.map((row) => (
          <tr key={row.id}>
            {row.getVisibleCells().map((cell) => (
              <td key={cell.id}>
                {flexRender(cell.column.columnDef.cell, cell.getContext())}
              </td>
            ))}
          </tr>
        ))}
      </tbody>
    </table>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't workingconfirmedThis bug was confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions