Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onHeaderRow] how to using onHeaderRow #610

Open
gladshop opened this issue May 5, 2021 · 1 comment
Open

[onHeaderRow] how to using onHeaderRow #610

gladshop opened this issue May 5, 2021 · 1 comment

Comments

@gladshop
Copy link

gladshop commented May 5, 2021

Hi, I want to custom align header and data but I can't see any example to use "onHeaderRow", does you give me any example using onHeaderRow to style or custom render header?

@Bhanukamax
Copy link

Bhanukamax commented Sep 23, 2021

@gladshop I had the same issue, there wasn't anything in the docs, and found your issue while searching for that, and I think there's a related issue which might help: #171

And found this on the source HeaderRow.tsx

...
if (onHeaderRow) {
    rowProps = onHeaderRow(
      cells.map(cell => cell.column),
      index,
    );
  }
...

Anyway, I figured it out from all of that 🙂. My use case was, I wanted to set some class names for the table header row, so here's what I did (there could be other ways to do it, but this kind of works for me), hope it helps.

      <Table
        columns={columns}
        data={data}
        onHeaderRow={() => ({
          className: "text-md font-semibold tracking-wide text-left text-gray-900 bg-gray-100 uppercase border-b border-gray-600 ",
        })}
      />

basically, you just need to return a object which has the props for the header row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants