Skip to content

MazTable

MazTable is designed to be a reusable data table with advanced features. Pagination, Search, Column Sorting, Row Selection, UI options, Loading and Slots.

Key Features

  1. 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 with no-paginate-rows.
  2. 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.
  3. Column Sorting (prop: sortable): Columns are sortable, indicated by arrow icons. Sorting can be activated by clicking on the column header.
  4. 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.
  5. Customizable Page Size: Users can choose the number of items to display per page using a dropdown list.
  6. 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.

#LastnameFirstnameAge
1 John Doe 99
2 Doe John 30

Advanced data table

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"

Competitions
#Name
Code
Type
Area
Actions
1
avatar image
UEFA Champions League
CLCUPEurope
2
avatar image
Premier League
PLLEAGUEEngland
3
avatar image
Serie A
SALEAGUEItaly
4
avatar image
FIFA World Cup
WCCUPWorld
5
avatar image
Primeira Liga
PPLLEAGUEPortugal
6
avatar image
Primera Division
PDLEAGUESpain
7
avatar image
Ligue 1
FL1LEAGUEFrance
8
avatar image
European Championship
ECCUPEurope
9
avatar image
Eredivisie
DEDLEAGUENetherlands
10
avatar image
Championship
ELCLEAGUEEngland

Loading

Enable the loading state with the prop loading

#LastnameFirstnameAge
1 John Doe 99
2 Doe John 33
3 Max Simth 66

Sizing

Available sizes: 'mini' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'

#LastnameFirstnameAge
1 John Doe 99

#LastnameFirstnameAge
1 John Doe 99

#LastnameFirstnameAge
1 John Doe 99

Types

Property row

The rows property is an array of Row: type Rows = Row[]

ts
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[]

ts
export interface MazTableHeadersEnriched {
  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

Props

NameDescriptionTypeRequiredDefaultPossible values
table-classCSS class of the table elementHTMLAttributes['class']Noundefined-
table-styleCSS style of the table elementHTMLAttributes['style']Noundefined-
model-valuev-model
List of selected rows
(string | boolean | number)[]Noundefined-
sizeSize of the tableMazSizeNo'md'xl, lg, md, sm, xs, mini
input-sizeSize of the search inputsMazSizeNoundefinedxl, lg, md, sm, xs, mini
titleTitle of the tablestringNoundefined-
headersHeaders of the tableMazTableHeader[]Noundefined-
sortableEnable sort feature on all columnsbooleanNofalse-
headers-alignAlign all headersstringNo'left'-
rowsRows of the tableT[]Noundefined-
hoverableAdd hover effect on rowsbooleanNofalse-
searchEnable search feature in table headerbooleanNofalse-
hide-search-in-rowDisable search in rows - useful to filter data yourself or make search request to serverbooleanNofalse-
hide-search-byDisable search by column (remove select input "search by")booleanNofalse-
search-queryv-model:search-query
Search query in input
stringNoundefined-
background-oddAdd background color to odd rowsbooleanNofalse-
background-evenAdd background color to even rowsbooleanNofalse-
elevationAdd shadow to the tablebooleanNofalse-
divideradd divider between rowsbooleanNofalse-
captionCaption of the tablestringNoundefined-
caption-sideCaption sidestringNo'bottom'top, bottom
paginationAdd pagination in table footerbooleanNofalse-
pagev-model:page
Current page of pagination
numberNo1-
page-sizev-model:page-size
Number of items per page
numberNo20-
total-pagesTotal number of pagesnumberNoundefined-
paginate-rowsDon't paginate rows - useful to make pagination request with your serverbooleanNotrue-
total-itemsTotal number of itemsnumberNoundefined-
loadingLoading statebooleanNofalse-
selectableEnable selection of rowsbooleanNofalse-
selected-keyEnable selection of rows - key of the selected rowstringNoundefined-
table-layoutTable layoutstringNoundefinedauto, fixed
colorColor of the componentMazColorNo'primary'-
translationsTranslations of the tableDeepPartial<MazUiTranslationsNestedSchema['table']>NoTranslations from @maz-ui/translations-
rounded-sizeSize radius of the component's borderstringNo'lg'none, sm, md, lg, xl, full
scrollableEnable scrollable on tablebooleanNofalse-

Events

Event namePropertiesDescription
update:model-valuevalue (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-querysearchQuery string - Search queryEmitted when entering a value in the search input
update:pagepage number - Current pageEmitted when the current page of pagination changes
update:page-sizepageSize number - Current page sizeEmitted when the page size of pagination changes

Slots

NameDescriptionBindings
titleReplace the title of the table
captionAdd caption on top or bottom of the table
theadContent in thead element
headerReplace column headerheader Object - Header data
label String - Header label
header-label-${header.key}Replace column header label
header Object - Header data
label String - Header label
actions-headerReplace text of actions header
default
selectReplace checkbox componentrow Object - Row data
selected Boolean - If selected or not
cellReplace all row cellsrow Object - Row data
value any - Cell value
cell-${key}Replace row cells of column
row Object - Row data
value any - Cell value
actionsAdd actions columnrow Object - Row data
no-resultsReplace the no results element
no-results-textreplace no results test only

MazTableCell

Slots

NameDescriptionBindings
default

MazTableRow

Props

NameDescriptionTypeRequired
hoverableOverride hoverable of table propsbooleanNo
is-headIf true, the row is a head rowbooleanNo

Slots

NameDescriptionBindings
default

MazTableTitle

Slots

NameDescriptionBindings
default