-
Notifications
You must be signed in to change notification settings - Fork 885
feat(Table): conditionally apply classes to tr
and td
#3866
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
Conversation
commit: |
src/runtime/components/Table.vue
Outdated
interface ColumnMeta<TData extends RowData, TValue> { | ||
class?: { | ||
th?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not handle function on th
as well? π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My use case involves highlighting a specific cell or row, for example, when a certain value in the row exceeds a threshold (e.g., "highlight the row in red if x > 10").
I donβt see a reason to modify the header cell, as it isnβt directly tied to any data.
That said, thinking about it now, there could be scenarios where it might be useful modifying the th
. For instance, "highlight the header with a color gradient based on the average of the column values?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think the th
should handle a function like td
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated also th
.
tr
and td
Thanks @andr35! π |
π Linked issue
Resolves #3865
β Type of change
π Description
In Nuxt UI v3, there is currently no way to apply custom styles or classes to individual table rows or cells. Additionally, it is not possible to dynamically set classes based on specific criteria, for example, the value of data displayed in a given cell.
This PR introduces the ability to:
meta.class.td
property of the columns prop to conditionally apply classes based on the cell's value.class.tr
property of table'smeta
to conditionally apply classes based on the row's data.π Checklist