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

Custom HTML for header cell #208

Open
isabellachen opened this issue Feb 16, 2024 · 1 comment
Open

Custom HTML for header cell #208

isabellachen opened this issue Feb 16, 2024 · 1 comment

Comments

@isabellachen
Copy link

Is it possible to do a custom header cell? For example, to wrap the header cell in a Popover component, so when the user hovers over the popover, they can see a tooltip explaining some caveats about the column data (e.g. data is an estimate).

Thank you!

@imballinst
Copy link
Owner

imballinst commented Feb 25, 2024

hi @isabellachen, apologies, I just saw this notification 🤦‍♂️ any chance you have found the solution?

At the moment, here's how I think we could do so: https://codesandbox.io/p/devbox/x7skdc?file=%2Fsrc%2Fstyles.css%3A4%2C27

{
  prop: "score",
  title: "Score",
  isSortable: true,
  thProps: {
    className: "hoverable",
  },
  headerCell: (sortIcon, sortState) => (
    <>
      Score2
      <span>{sortIcon}</span>
      <div className="popover">Test popover</div>
    </>
  ),
},

Then, in CSS:

.hoverable > .popover {
  display: none;
  padding: 4px;
  border: 1px solid black;
  position: absolute;
}

.hoverable:hover > .popover {
  display: block;
  position: absolute;
}

(I think similar approach could be used with similar libraries as well, e.g. Popper.js)

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