-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Description
Hi, first of all thanks for Nuxt UI, it's a great library that makes building interfaces in Nuxt fast and enjoyable. Really appreciate the work you're putting into it.
Context
The <UTable> component currently supports conditional class names via meta.class.tr (from TableMeta) and meta.class.th / meta.class.td (from ColumnMeta). This works well in most cases with Tailwind.
However, it’s not possible today to apply inline styles dynamically — for example, to set background colors or custom widths based on data. This creates limitations in use cases where:
- Tailwind classes are too generic or not granular enough
- Style values are truly dynamic (e.g. coming from user data or configs)
Proposal
Add support for meta.style, mirroring the structure of meta.class, with the following API shape:
meta {
style?: {
tr?: string | ((row: Row<TData>) => string);
};
}
meta: {
style?: {
th?: string | ((cell: Header<TData, TValue>) => string);
td?: string | ((cell: Cell<TData, TValue>) => string);
}
}Example usage
<UTable
:data="data"
:columns="columns"
:meta="{
style: {
tr: row => row.age < 18 ? { backgroundColor: '#fff0f0' } : {},
}
}"
/>Why this matters
- It improves flexibility for styling without requiring full slot overrides
- It handles dynamic styles that can’t be expressed with Tailwind classes
- It aligns with the existing
meta.classdesign in bothTableMetaandColumnMeta, keeping things consistent and declarative
Additional context
No response
Reactions are currently unavailable