MazTable
MazTable is designed to be a reusable data table with advanced features. Pagination, Search, Column Sorting, Row Selection, UI options, Loading and Slots.
INFO
Before you have to import the global css files in your project, follow instructions in Getting Started
Key Features
- Pagination (prop
pagination
)- The component supports pagination with buttons to go to the first, previous, next, and last page.
- You can display only the pagination elements (input and buttons) and make API calls to your server to get elements by using the prop
pagination
withno-paginate-rows
.
- Search (prop
search
): It includes a search feature with a search bar where users can enter a query to filter displayed data. You can choose the column where the search will be activated. - Column Sorting (prop:
sortable
): Columns are sortable, indicated by arrow icons. Sorting can be activated by clicking on the column header. - Row Selection (prop
select-value="key"
): There is a dedicated column for selection with a checkbox for each row. Users can individually or collectively select/deselect rows. - Customizable Page Size: Users can choose the number of items to display per page using a dropdown list.
- Loading Indicator (prop
loading
): A loading indicator (MazLoadingBar) is displayed when data is being loaded.
Available models
- v-model:
(string | boolean | number)[] | undefined
(list of selected key) - v-model:search-query:
string | undefined
- v-model:page:
number
- v-model:page-size:
number
Basic usage
You can use MazTable and his child component to build a simple table and enjoy the style.
# | Lastname | Firstname | Age |
---|---|---|---|
1 | John | Doe | 99 |
2 | Doe | John | 30 |
Advanced
You can also provide all your data, the table is auto-generated and you can use the features listed on top
v-model="[ "0262672d-7c7a-4d30-866e-edb88b5a5336" ]"
v-model:search-query="undefined"
v-model:page="1"
v-model:page-size="10"
# | Name | Code | Type | Area | Actions | |
---|---|---|---|---|---|---|
1 | UEFA Champions League | CL | CUP | Europe | ||
2 | Premier League | PL | LEAGUE | England | ||
3 | Serie A | SA | LEAGUE | Italy | ||
4 | FIFA World Cup | WC | CUP | World | ||
5 | Primeira Liga | PPL | LEAGUE | Portugal | ||
6 | Primera Division | PD | LEAGUE | Spain | ||
7 | Ligue 1 | FL1 | LEAGUE | France | ||
8 | European Championship | EC | CUP | Europe | ||
9 | Eredivisie | DED | LEAGUE | Netherlands | ||
10 | Championship | ELC | LEAGUE | England |
Loading
Enable the loading state with the prop loading
# | Lastname | Firstname | Age |
---|---|---|---|
1 | John | Doe | 99 |
2 | Doe | John | 33 |
3 | Max | Simth | 66 |
Sizing
Available sizes: 'mini' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
# | Lastname | Firstname | Age |
---|---|---|---|
1 | John | Doe | 99 |
# | Lastname | Firstname | Age |
---|---|---|---|
1 | John | Doe | 99 |
# | Lastname | Firstname | Age |
---|---|---|---|
1 | John | Doe | 99 |
Types
Property row
The rows
property is an array of Row: type Rows = Row[]
type Row = Record<string, any> & {
selected?: boolean
action?: (row: Row) => unknown
classes?: HTMLAttributes['class']
}
Property headers
The headers
property has type: type Headers = string | HeadersEnriched[]
type HeadersEnriched = {
label: string
key?: string
sortable?: boolean
hidden?: boolean
srOnly?: boolean
width?: string
maxWidth?: string
classes?: ThHTMLAttributes['class']
scope?: ThHTMLAttributes['scope']
align?: ThHTMLAttributes['align']
rowspan?: ThHTMLAttributes['rowspan']
colspan?: ThHTMLAttributes['colspan']
headers?: ThHTMLAttributes['headers']
}
Props & Events emitted
MazTable
Props, Event & Slots
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
tableClass | class of the table element | TSIndexedAccessType | - | undefined |
tableStyle | style of the table element | StyleValue | - | undefined |
modelValue | v-model of the table - list of selected rows | Array | - | undefined |
size | size of the table@values 'xl' | 'lg' | 'md' | 'sm' | 'xs' | 'mini' @default 'md' | Size | - | 'md' |
inputSize | Size of the search inputs@values 'xl' | 'lg' | 'md' | 'sm' | 'xs' | 'mini' | Size | - | |
title | title of the table | string | - | undefined |
headers | headers of the table | Array | - | undefined |
sortable | allow sort feature to all columns | boolean | - | |
headersAlign | align all headers | TSIndexedAccessType | - | 'left' |
rows | rows of the table - type: Record<string, string | boolean | number>[] ; | Array | - | undefined |
hoverable | add hover effect on rows | boolean | - | |
search | enable search feature into the table header | boolean | - | |
noSearchInRow | disabled search in rows - useful to filtering data yourself or make search request to server | boolean | - | |
searchPlaceholder | placeholder of the search input | string | - | 'Search' |
noSearchBy | Disabled search by column (remove select input "search by") | boolean | - | |
searchByPlaceholder | placeholder of the search by select | string | - | 'Search by' |
searchByAllLabel | label of the search by of all options | string | - | 'All' |
searchQuery | search query in input | string | - | undefined |
backgroundOdd | add background color to odd rows | boolean | - | |
backgroundEven | add background color to even rows | boolean | - | |
elevation | add shodow to the table | boolean | - | |
divider | no divider between rows | boolean | - | |
caption | caption of the table | string | - | undefined |
captionSide | caption side@values 'top' | 'bottom' | union | - | 'bottom' |
pagination | add pagination into the table footer | boolean | - | |
page | current page of pagination | number | - | 1 |
pageSize | number of items per page | number | - | 20 |
totalPages | pages count | number | - | undefined |
paginationAllLabel | label of the pagination all option | string | - | 'All' |
noPaginateRows | no paginate rows - useful to make paginate request with your server | boolean | - | |
totalItems | total number of items | number | - | undefined |
loading | loading state | boolean | - | |
selectable | Enable selection of rows | boolean | - | |
selectedKey | Enable selection of rows - key of the selected row | string | - | undefined |
tableLayout | table layout@values 'auto' | 'fixed' | union | - | undefined |
color | color of the loading bar | Color | - | 'primary' |
translations | translations@default { searchByAllLabel: 'All', searchByPlaceholder: 'Search by', searchPlaceholder: 'Search', paginationAllLabel: 'All', noResults: 'No results' } | Translations | - | |
roundedSize | Size of the rounded@values 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full' @default 'lg' | union | - | 'lg' |
Events
Event name | Properties | Description |
---|---|---|
update:model-value | value (Row | string | number | boolean)[] - list of selected rows (if selectedKey is defined, it will be the value of the selectedKey of the row) | emitted when a row is selected |
update:search-query | searchQuery string - search query | emitted when enter a value in the search input |
update:page | page number - current page | emitted when the current page of the pagination change |
update:page-size | pageSize number - current page size | emitted when the page size of the pagination change |
Slots
Name | Description | Bindings |
---|---|---|
title | ||
caption | add caption on top or bottom of the table | |
thead | content in thead element | |
header | replace column header | header Object - header datalabel String - header label |
header-label- | replace column header label | header Object - header datalabel String - header label |
actions-header | replace text of actions header | |
default | ||
select | replace checkbox component | row Object - row dataselected Boolean - if selected or not |
cell | replace all row cells | row Object - row datavalue Boolean - cell value |
cell- | replace row cells of column | row Object - row datavalue Boolean - cell value |
actions | will add actions column | row Object - row data |
no-results | replace no results | |
no-results-text | replace no results test only |
MazTableCell
Props & Slots
Slots
Name | Description | Bindings |
---|---|---|
default |
MazTableRow
Props & Slots
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
noHoverable | Override hoverable of table props | boolean | - |
Slots
Name | Description | Bindings |
---|---|---|
default |
MazTableTitle
Props & Slots
Slots
Name | Description | Bindings |
---|---|---|
default |