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

[Table] Support for slots in templates #2449

Closed
hywax opened this issue Oct 24, 2024 · 2 comments
Closed

[Table] Support for slots in templates #2449

hywax opened this issue Oct 24, 2024 · 2 comments
Labels
enhancement New feature or request v3 #1289

Comments

@hywax
Copy link
Collaborator

hywax commented Oct 24, 2024

For what version of Nuxt UI are you asking this question?

v3-alpha

Description

@benjamincanac Hi, will there be support for the same slots in v3 table as in v2? Passing render functions is very inconvenient, I want api like in v2.

Just yesterday you made a table #2364 , but you added slots only in render

@hywax hywax added the question Further information is requested label Oct 24, 2024
@miguelrk
Copy link

Following up on this, I'm wondering if <script setup lang="tsx"> would work?

This would avoid the less-convenient DX of h() render functions. For instance, would this work?

<script setup lang="tsx">
import type { TableColumn } from '@nuxt/ui'

const data = ref([...])

const columns: TableColumn[] = [
  {
    accessorKey: 'id',
    header: 'ID',
    cell: ({ row }) => (
      <div>
        {row.getValue('id')}
      </div>
    )
  },
  {
    accessorKey: 'date',
    header: 'Date',
    cell: ({ row }) => (
      <div>
        {row.getValue('date')}
      </div>
    )
  },
]
</script>

<template>
  <UTable :data="data" :columns="columns"/>
</template>

This would be great for the DX, but in general, the ability to also pass render functions is great IMO, especially if TSX can be used out of the box.

@benjamincanac benjamincanac added v3 #1289 enhancement New feature or request and removed question Further information is requested labels Oct 28, 2024
@benjamincanac
Copy link
Member

@miguelrk Just tried it and it works 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v3 #1289
Projects
None yet
Development

No branches or pull requests

3 participants