feat(data-table): add custom header renderer#397
Open
IzumiSy wants to merge 6 commits into
Open
Conversation
IzumiSy
force-pushed
the
feat/data-table-header-renderer
branch
from
July 23, 2026 07:58
a3e0543 to
60ca0a5
Compare
IzumiSy
marked this pull request as ready for review
July 24, 2026 05:00
Contributor
Author
|
/review |
Contributor
|
✅ API Design Review completed successfully! |
Contributor
There was a problem hiding this comment.
Generated by API Design Review for issue #397 · 24.7 AIC · ⌖ 6.01 AIC · ⊞ 5.8K
Comment /review to run again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
DataTablecurrently only exposeslabelfor column headers, which makes common customizations like icons, partial text styling, or sort-aware header affordances awkward or impossible without forking the built-in header renderer.This change adds a small header customization API that covers those use cases while preserving the existing built-in table header structure, sticky behavior, sort click handling, and sort indicator rendering.
Design Decision
Chosen approach
Add a
headerfield toColumnthat accepts either a staticReactNodeor a render function.The render function receives a narrow
HeaderRenderContextinstead of the whole table/control state. That keeps the API focused on header rendering and avoids coupling column definitions to internal sort policy details.Sort interaction
Sortable headers receive
{ label, sortable: true, sortDirection, activateSort }.Non-sortable headers receive
{ label, sortable: false }.This keeps the type surface explicit: custom headers can read sort state and trigger the built-in sort action when sorting is actually active, but they do not need to reimplement the sort direction cycle themselves.
Alternatives considered
A full header-cell renderer or raw sort-control API would be more flexible, but it would also make it easier to break shared behavior such as sticky headers, click targets, sort indicators, and accessibility. The smaller
headerAPI is enough for the current use cases without opening that larger escape hatch.Summary
Column.headerfor static or render-function-based custom header contentHeaderRenderContextwith sort-aware data andactivateSort()only when sorting is active