Skip to content

Commit

Permalink
feat(Table): allow columns class customization
Browse files Browse the repository at this point in the history
Resolves #366
  • Loading branch information
benjamincanac committed Jun 29, 2023
1 parent cbd8cc4 commit 5dffa86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/content/4.data/1.table.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Use the `columns` prop to configure which columns to display. It's an array of o
- `key` - The field to display from the row data.
- `sortable` - Whether the column is sortable. Defaults to `false`.
- `direction` - The sort direction to use on first click. Defaults to `asc`.
- `class` - The class to apply to the column cells.

::component-example{class="grid"}
---
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/components/data/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UCheckbox :checked="indeterminate || selected.length === rows.length" :indeterminate="indeterminate" @change="selected = $event.target.checked ? rows : []" />
</th>

<th v-for="(column, index) in columns" :key="index" scope="col" :class="[ui.th.base, ui.th.padding, ui.th.color, ui.th.font, ui.th.size]">
<th v-for="(column, index) in columns" :key="index" scope="col" :class="[ui.th.base, ui.th.padding, ui.th.color, ui.th.font, ui.th.size, column.class]">
<slot :name="`${column.key}-header`" :column="column" :sort="sort" :on-sort="onSort">
<UButton
v-if="column.sortable"
Expand Down Expand Up @@ -96,7 +96,7 @@ export default defineComponent({
default: () => []
},
columns: {
type: Array as PropType<{ key: string, sortable?: boolean, [key: string]: any }[]>,
type: Array as PropType<{ key: string, sortable?: boolean, class?: string, [key: string]: any }[]>,
default: null
},
columnAttribute: {
Expand Down

0 comments on commit 5dffa86

Please sign in to comment.