-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Benjamin Canac <[email protected]>
- Loading branch information
1 parent
45171e2
commit ef561e7
Showing
6 changed files
with
542 additions
and
10 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
docs/app/components/content/examples/table/TableSlotsExample.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<script setup lang="ts"> | ||
import type { TableColumn } from '@nuxt/ui' | ||
type User = { | ||
id: number | ||
name: string | ||
position: string | ||
email: string | ||
role: string | ||
} | ||
const data = ref<User[]>([{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
position: 'Front-end Developer', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 2, | ||
name: 'Courtney Henry', | ||
position: 'Designer', | ||
email: '[email protected]', | ||
role: 'Admin' | ||
}, { | ||
id: 3, | ||
name: 'Tom Cook', | ||
position: 'Director of Product', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 4, | ||
name: 'Whitney Francis', | ||
position: 'Copywriter', | ||
email: '[email protected]', | ||
role: 'Admin' | ||
}, { | ||
id: 5, | ||
name: 'Leonard Krasner', | ||
position: 'Senior Designer', | ||
email: '[email protected]', | ||
role: 'Owner' | ||
}, { | ||
id: 6, | ||
name: 'Floyd Miles', | ||
position: 'Principal Designer', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}]) | ||
const columns: TableColumn<User>[] = [{ | ||
accessorKey: 'id', | ||
header: 'ID' | ||
}, { | ||
accessorKey: 'name', | ||
header: 'Name' | ||
}, { | ||
accessorKey: 'email', | ||
header: 'Email' | ||
}, { | ||
accessorKey: 'role', | ||
header: 'Role' | ||
}] | ||
</script> | ||
|
||
<template> | ||
<UTable :data="data" :columns="columns" class="flex-1"> | ||
<template #name-cell="{ row }"> | ||
<div class="flex items-center gap-3"> | ||
<UAvatar :src="`https://i.pravatar.cc/120?img=${row.original.id}`" size="lg" /> | ||
<div> | ||
<p class="font-medium text-[var(--ui-text-highlighted)]"> | ||
{{ row.original.name }} | ||
</p> | ||
<p> | ||
{{ row.original.position }} | ||
</p> | ||
</div> | ||
</div> | ||
</template> | ||
</UTable> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.