diff --git a/docs/app/components/content/examples/table/TableColumnsExample.vue b/docs/app/components/content/examples/table/TableColumnsExample.vue
new file mode 100644
index 0000000000..0023368e1a
--- /dev/null
+++ b/docs/app/components/content/examples/table/TableColumnsExample.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
diff --git a/docs/content/3.components/table.md b/docs/content/3.components/table.md
index 0f8eeac99f..cf90a2db99 100644
--- a/docs/content/3.components/table.md
+++ b/docs/content/3.components/table.md
@@ -12,6 +12,172 @@ links:
## Usage
+### Data
+
+Use the `data` prop as an array of objects, the columns will be generated based on the keys of the objects.
+
+::component-code
+---
+collapse: true
+class: '!p-0'
+ignore:
+ - data
+ - class
+external:
+ - data
+props:
+ data:
+ - id: '4600'
+ date: '2024-03-11T15:30:00'
+ status: 'paid'
+ email: 'james.anderson@example.com'
+ amount: 594
+ - id: '4599'
+ date: '2024-03-11T10:10:00'
+ status: 'failed'
+ email: 'mia.white@example.com'
+ amount: 276
+ - id: '4598'
+ date: '2024-03-11T08:50:00'
+ status: 'refunded'
+ email: 'william.brown@example.com'
+ amount: 315
+ - id: '4597'
+ date: '2024-03-10T19:45:00'
+ status: 'paid'
+ email: 'emma.davis@example.com'
+ amount: 529
+ - id: '4596'
+ date: '2024-03-10T15:55:00'
+ status: 'paid'
+ email: 'ethan.harris@example.com'
+ amount: 639
+ class: 'flex-1'
+---
+::
+
+### Columns
+
+Use the `columns` prop as an array of objects with the following properties:
+
+- `accessorKey`: The key of the column.
+- `header`: The header of the column.
+- `footer`: The footer of the column.
+
+::component-example
+---
+collapse: true
+class: '!p-0'
+name: 'table-columns-example'
+---
+::
+
+::note{to="https://tanstack.com/table/latest/docs/guide/column-defs" target="_blank"}
+For more information on columns, see the [TanStack Table documentation](https://tanstack.com/table/latest/docs/guide/column-defs).
+::
+
+### Sticky
+
+Use the `sticky` prop to make the header sticky.
+
+::component-code
+---
+collapse: true
+class: '!p-0'
+ignore:
+ - data
+ - class
+external:
+ - data
+props:
+ sticky: true
+ data:
+ - id: '4600'
+ date: '2024-03-11T15:30:00'
+ status: 'paid'
+ email: 'james.anderson@example.com'
+ amount: 594
+ - id: '4599'
+ date: '2024-03-11T10:10:00'
+ status: 'failed'
+ email: 'mia.white@example.com'
+ amount: 276
+ - id: '4598'
+ date: '2024-03-11T08:50:00'
+ status: 'refunded'
+ email: 'william.brown@example.com'
+ amount: 315
+ - id: '4597'
+ date: '2024-03-10T19:45:00'
+ status: 'paid'
+ email: 'emma.davis@example.com'
+ amount: 529
+ - id: '4596'
+ date: '2024-03-10T15:55:00'
+ status: 'paid'
+ email: 'ethan.harris@example.com'
+ amount: 639
+ - id: '4595'
+ date: '2024-03-10T15:55:00'
+ status: 'paid'
+ email: 'ethan.harris@example.com'
+ amount: 639
+ - id: '4594'
+ date: '2024-03-10T15:55:00'
+ status: 'paid'
+ email: 'ethan.harris@example.com'
+ amount: 639
+ class: 'flex-1 max-h-[312px]'
+---
+::
+
+### Loading
+
+Use the `loading` prop to display a loading state, the `loading-color` prop to change its color and the `loading-animation` prop to change its animation.
+
+::component-code
+---
+collapse: true
+class: '!p-0'
+ignore:
+ - data
+ - class
+external:
+ - data
+props:
+ loading: true
+ loadingColor: primary
+ loadingAnimation: carousel
+ data:
+ - id: '4600'
+ date: '2024-03-11T15:30:00'
+ status: 'paid'
+ email: 'james.anderson@example.com'
+ amount: 594
+ - id: '4599'
+ date: '2024-03-11T10:10:00'
+ status: 'failed'
+ email: 'mia.white@example.com'
+ amount: 276
+ - id: '4598'
+ date: '2024-03-11T08:50:00'
+ status: 'refunded'
+ email: 'william.brown@example.com'
+ amount: 315
+ - id: '4597'
+ date: '2024-03-10T19:45:00'
+ status: 'paid'
+ email: 'emma.davis@example.com'
+ amount: 529
+ - id: '4596'
+ date: '2024-03-10T15:55:00'
+ status: 'paid'
+ email: 'ethan.harris@example.com'
+ amount: 639
+ class: 'flex-1'
+---
+::
+
## Examples
## API
diff --git a/docs/nuxt.config.ts b/docs/nuxt.config.ts
index eb7ebdbf19..177c15f800 100644
--- a/docs/nuxt.config.ts
+++ b/docs/nuxt.config.ts
@@ -179,6 +179,7 @@ export default defineNuxtConfig({
'USlider',
'USlideover',
'USwitch',
+ 'UTable',
'UTabs',
'UTextarea',
'UTooltip'
diff --git a/playground/app/pages/components/table.vue b/playground/app/pages/components/table.vue
index 8477478d22..867fe2364c 100644
--- a/playground/app/pages/components/table.vue
+++ b/playground/app/pages/components/table.vue
@@ -20,7 +20,7 @@ type Payment = {
const table = useTemplateRef('table')
-const data: Payment[] = [{
+const data = ref([{
id: '4600',
date: '2024-03-11T15:30:00',
status: 'paid',
@@ -140,7 +140,7 @@ const data: Payment[] = [{
status: 'paid',
email: 'logan.baker@example.com',
amount: 567
-}]
+}])
const columns: TableColumn[] = [{
id: 'select',
@@ -258,10 +258,21 @@ const columns: TableColumn[] = [{
}
}]
+const loading = ref(true)
const columnPinning = ref({
left: ['id'],
right: ['actions']
})
+
+function randomize() {
+ data.value = [...data.value].sort(() => Math.random() - 0.5)
+}
+
+onMounted(() => {
+ setTimeout(() => {
+ loading.value = false
+ }, 1300)
+})
@@ -274,6 +285,8 @@ const columnPinning = ref({
@update:model-value="table?.tableApi?.getColumn('email')?.setFilterValue($event)"
/>
+
+
{{ row.original }}
diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue
index 55f072b0c3..7850e46b3a 100644
--- a/src/runtime/components/Table.vue
+++ b/src/runtime/components/Table.vue
@@ -1,19 +1,9 @@