Skip to content

Support inline style in <UTable> via meta.style #4475

@Flamystal

Description

@Flamystal

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.class design in both TableMeta and ColumnMeta, keeping things consistent and declarative

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv3#1289

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions