Appearance
Table
The FTTable component replaces the standard html button with a design theme and a multitude of options.
Usage
Buttons in their simplest form contain uppercase text, a slight elevation, hover effect, and a ripple effect on click.
Composition api (script setup)
vue
<script setup lang="ts">
import { FTTable } from '@fasttrack-solutions/vue-components-lib';
</script><script setup lang="ts">
import { FTTable } from '@fasttrack-solutions/vue-components-lib';
</script>Options api
vue
<script>
import { FTButton } from '@fasttrack-solutions/vue-components-lib';
export default {
components: {
FTTable
}
}
</script><script>
import { FTButton } from '@fasttrack-solutions/vue-components-lib';
export default {
components: {
FTTable
}
}
</script>Simple Headers
Buttons in their simplest form contain uppercase text, a slight elevation, hover effect, and a ripple effect on click.
| Test | Test2 |
|---|---|
| 0 | Row 0 |
| 1 | Row 1 |
| 2 | Row 2 |
| 3 | Row 3 |
vue
<script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems"></FTTable><script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems"></FTTable>Advanced Headers
You can pass a list of objects to heads to enable things like sorting
| Test | Test 2 |
|---|---|
| 0 | Row 0 |
| 1 | Row 1 |
| 2 | Row 2 |
| 3 | Row 3 |
vue
<script lang="ts" setup>
const headsAdvanced = [
{ label: 'Test', sortable: true, sortKey: 'id' },
{
label: 'Test 2',
sortable: true,
sortKey: 'name',
class: 'column--2',
},
];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsAdvanced" :items="tableItems"></FTTable><script lang="ts" setup>
const headsAdvanced = [
{ label: 'Test', sortable: true, sortKey: 'id' },
{
label: 'Test 2',
sortable: true,
sortKey: 'name',
class: 'column--2',
},
];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsAdvanced" :items="tableItems"></FTTable>Custom headers
Buttons in their simplest form contain uppercase text, a slight elevation, hover effect, and a ripple effect on click.
| Test | Test2 | |
|---|---|---|
| 0 | This is Row 0 | |
| 1 | This is Row 1 | |
| 2 | This is Row 2 | |
| 3 | This is Row 3 |
vue
<script lang="ts" setup>
import { FTCheckbox } from '@fasttrack-solutions/vue-components-lib';
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :items="tableItems">
<template #head>
<th><FTCheckbox></FTCheckbox></th>
<th v-for="head in headsSimple">
{{head}}
</th>
</template>
<template #row="item">
<tr class="tr--clickable" @click="clickRow(item)">
<td>
<FTCheckbox></FTCheckbox>
</td>
<td>
{{ item.id }}
</td>
<td>
This is {{ item.name }}
</td>
</tr>
</template>
</FTTable><script lang="ts" setup>
import { FTCheckbox } from '@fasttrack-solutions/vue-components-lib';
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :items="tableItems">
<template #head>
<th><FTCheckbox></FTCheckbox></th>
<th v-for="head in headsSimple">
{{head}}
</th>
</template>
<template #row="item">
<tr class="tr--clickable" @click="clickRow(item)">
<td>
<FTCheckbox></FTCheckbox>
</td>
<td>
{{ item.id }}
</td>
<td>
This is {{ item.name }}
</td>
</tr>
</template>
</FTTable>Custom rows
Buttons in their simplest form contain uppercase text, a slight elevation, hover effect, and a ripple effect on click.
| Test | Test2 |
|---|---|
| 0 | This is Row 0 |
| 1 | This is Row 1 |
| 2 | This is Row 2 |
| 3 | This is Row 3 |
vue
<script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems">
<template #row="item">
<tr class="tr--clickable" @click="clickRow(item)">
<td>
{{ item.id }}
</td>
<td>
This is {{ item.name }}
</td>
</tr>
</template>
</FTTable><script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems">
<template #row="item">
<tr class="tr--clickable" @click="clickRow(item)">
<td>
{{ item.id }}
</td>
<td>
This is {{ item.name }}
</td>
</tr>
</template>
</FTTable>No striped rows
Make every row the same color
| Test | Test2 |
|---|---|
| 0 | Row 0 |
| 1 | Row 1 |
| 2 | Row 2 |
| 3 | Row 3 |
vue
<script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems" no-stripes></FTTable><script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 4; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems" no-stripes></FTTable>With paging
| Test | Test2 |
|---|---|
| 0 | Row 0 |
| 1 | Row 1 |
| 2 | Row 2 |
| 3 | Row 3 |
| 4 | Row 4 |
vue
<script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 50; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems" with-paging :default-page-size="5"></FTTable><script lang="ts" setup>
const headsSimple = ['Test', 'Test2'];
const tableItems = ref([]);
for (let i = 0; i < 50; i += 1) {
tableItems.value.push({
id: i,
name: `Row ${i}`,
});
}
</script>
<FTTable :heads="headsSimple" :items="tableItems" with-paging :default-page-size="5"></FTTable>Props
In addition to the standard attributes supported but HTML button FTButton accepts custom helper props
| Name | Default | Description |
|---|---|---|
withPaging | false | Whether to display pagination |
noStripes | false | Disable zebra striped rows |
heads | [] | Table head items |
items | [] | Table rows |
Props related to paging
FTPaging contains all the information regarding the pagination
| Name | Default | Description |
|---|---|---|
defaultPageSize | 25 | Number of items to show per page |
showFirstPage | false | Show a go to first page in paginator |
showLastPage | false | Show a go to last page in paginator |
storeSortKey | empty | If set will set an item in localStorage to remember sortKer and sortOrder |
defaultSortKey | empty | Default key to sort on |
defaultSortOrder | desc | Default order for sorting |
CSS
Most of the default styles are setup using CSS variables for easy customization on a per project basis.
| CSS variable | Default Value |
|---|---|
--ft-table-row-padding | 12px 10px |
--ft-table-row-background--hover | #eceff1 |
--ft-table-row-background-odd-line | #f9f9f9 |
--ft-table-head-border | 2px solid #f5f5f5 |