mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(Table): add ability to custom style for td and tr (#741)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8b7a013319
commit
874447cb41
@@ -524,6 +524,65 @@ excludedProps:
|
||||
---
|
||||
::
|
||||
|
||||
## Styling
|
||||
|
||||
You can apply styles to `tr` and `td` elements by passing a `class` to rows.
|
||||
|
||||
Also, you can apply styles to `th` elements by passing a `class` to columns.
|
||||
|
||||
::component-example
|
||||
---
|
||||
padding: false
|
||||
---
|
||||
|
||||
#default
|
||||
:table-example-style{class="w-full"}
|
||||
|
||||
#code
|
||||
```vue
|
||||
<script setup>
|
||||
const columns = [{
|
||||
key: 'id',
|
||||
label: '#'
|
||||
}, {
|
||||
key: 'quantity',
|
||||
label: 'Quantity',
|
||||
class: 'italic' // Apply style to column header
|
||||
}, {
|
||||
key: 'name',
|
||||
label: 'Name'
|
||||
}]
|
||||
|
||||
const items = [{
|
||||
id: 1,
|
||||
name: 'Apple',
|
||||
quantity: { value: 100, class: 'bg-green-500/50 dark:bg-green-400/50' } // Apply style to td
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'Orange',
|
||||
quantity: { value: 0 },
|
||||
class: 'bg-red-500/50 dark:bg-red-400/50 animate-pulse' // Apply style to tr
|
||||
}, {
|
||||
id: 3,
|
||||
name: 'Banana',
|
||||
quantity: { value: 30, class: 'bg-green-500/50 dark:bg-green-400/50' }
|
||||
}, {
|
||||
id: 4,
|
||||
name: 'Mango',
|
||||
quantity: { value: 5, class: 'bg-green-500/50 dark:bg-green-400/50' }
|
||||
}]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UTable :rows="items" :columns="columns">
|
||||
<template #quantity-data="{ row }">
|
||||
{{ row.quantity.value }}
|
||||
</template>
|
||||
</UTable>
|
||||
</template>
|
||||
```
|
||||
::
|
||||
|
||||
## Slots
|
||||
|
||||
You can use slots to customize the header and data cells of the table.
|
||||
|
||||
Reference in New Issue
Block a user