Table
Tabulated data are sometimes needed, it's even better when it's responsive
Examples
Base
Show code
Column prop
Show code
Customise
Show code
Selection
Show code
Checkable
Show code
Detailed
Show code
Pagination
Show code
Async Data
Show code
Sticky
Show code
Searchable
Show code
Draggable rows/columns
Show code
Class props
Table component
Tabulated data are sometimes needed, it's even better when it's responsive
html
<o-table></o-table>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
ariaCurrentLabel | Accessibility label for the pagination current page button. | string | - | From config: table: { |
ariaNextLabel | Accessibility label for the pagination next page button. | string | - | From config: table: { |
ariaPageLabel | Accessibility label for the pagination page button. | string | - | From config: table: { |
ariaPreviousLabel | Accessibility label for the pagination previous page button. | string | - | From config: table: { |
backendFiltering | Columns won't be filtered with Javascript, use with searchable prop to the columns to filter in your backend | boolean | - | From config: table: { |
backendPagination | Rows won't be paginated with Javascript, use with page-change event to paginate in your backend | boolean | - | false |
backendSorting | Columns won't be sorted with Javascript, use with sort event to sort in your backend | boolean | - | From config: table: { |
bordered | Border to all cells | boolean | - | From config: table: { |
checkable | Rows can be checked (multiple) | boolean | - | false |
checkboxPosition | Position of the checkbox when checkable | string | left , right | From config: table: { |
checkboxVariant | Color of the checkbox when checkable | string | primary , info , success , warning , danger , and any other custom color | From config: table: { |
checkedRows | Set which rows are checked, use v-model:checkedRows to make it two-way binding | array | - | [] |
columns | Table columns | Column[] | - | Default function (see source code) |
currentPage | Current page of table data (if paginated), use v-model:currentPage to make it two-way binding | number | - | 1 |
customDetailRow | Custom style on details | boolean | - | false |
customIsChecked | Custom method to verify if row is checked, works when is checkable. Useful for backend pagination | (row: unknown, data: unknown[]) => boolean | - | |
customRowKey | Use a unique key of your data Object for each row. Useful if your data prop has dynamic indices. (id recommended) | string | - | From config: table: { |
data | Table data | unknown[] | - | Default function (see source code) |
debounceSearch | Filtering debounce time (in milliseconds) | number | - | From config: table: { |
defaultSort | Sets the default sort column and order — e.g. ['first_name', 'desc'] | string | string[] | - | From config: table: { |
defaultSortDirection | Sets the default sort column direction on the first click | string | asc , desc | From config: table: { |
detailIcon | Icon name of detail action | string | - | From config: table: { |
detailKey | Use a unique key of your data Object when use detailed or opened detailed. (id recommended) | string | - | From config: table: { |
detailTransition | string | - | From config: table: { | |
detailed | Allow row details | boolean | - | false |
draggable | Allows rows to be draggable | boolean | - | false |
draggableColumn | Allows columns to be draggable | boolean | - | false |
filtersEvent | Add a native event to filter | string | - | "" |
focusable | Table can be focused and user can navigate with keyboard arrows (require selected) and rows are highlighted when hovering | boolean | - | false |
hasDetailedVisible | Controls the visibility of the trigger that toggles the detailed rows. | (row: unknown) => boolean | - | From config: table: { |
headerCheckable | Show check/uncheck all checkbox in table header when checkable | boolean | - | true |
height | Table fixed height | number|string | - | |
hoverable | Rows are highlighted when hovering | boolean | - | From config: table: { |
iconPack | Icon pack to use | string | mdi , fa , fas and any other custom icon pack | From config: table: { |
isRowCheckable | Custom method to verify if a row is checkable, works when is checkable | (row: unknown) => boolean | - | From config: table: { |
isRowSelectable | Custom method to verify if a row is selectable, works when is selected. | func | - | Default function (see source code) |
loading | Enable loading state | boolean | - | false |
mobileBreakpoint | Mobile breakpoint as max-width value | string | - | From config: table: { |
mobileCards | Rows appears as cards on mobile (collapse rows) | boolean | - | From config: table: { |
mobileSortPlaceholder | Text when nothing is selected | string | - | From config: table: { |
narrowed | Makes the cells narrower | boolean | - | From config: table: { |
openedDetailed | Allow pre-defined opened details. Ideal to open details via vue-router. (A unique key is required; check detail-key prop) | array | - | [] |
override | Override existing theme classes completely | boolean | - | |
paginated | Adds pagination to the table | boolean | - | From config: table: { |
paginationOrder | Pagination buttons order if paginated | string | centered , right , left | From config: table: { |
paginationPosition | Pagination position (if paginated) | string | bottom , top , both | From config: table: { |
paginationRounded | Rounded pagination if paginated | boolean | - | From config: table: { |
paginationSimple | Enable simple style pagination if paginated | boolean | - | From config: table: { |
paginationSize | Size of pagination if paginated | string | - | From config: table: { |
perPage | How many rows per page (if paginated) | number|string | - | From config: table: { |
rowClass | Add a class to row based on the return | (row: unknown, index: number) => string | - | From config: table: { |
scrollable | Add a horizontal scrollbar when table is too wide | boolean | - | |
selected | Set which row is selected, use v-model:selected to make it two-way binding | object | - | |
showDetailIcon | Allow chevron icon and column to be visible | boolean | - | From config: table: { |
showHeader | Show header | boolean | - | From config: table: { |
sortIcon | Sets the header sorting icon | string | - | From config: table: { |
sortIconSize | Sets the size of the sorting icon | string | small , medium , large | From config: table: { |
stickyCheckbox | Make the checkbox column sticky when checkable | boolean | - | false |
stickyHeader | Show a sticky table header | boolean | - | false |
striped | Whether table is striped | boolean | - | From config: table: { |
total | Total number of table data if backend-pagination is enabled | number | - | 0 |
Events
Event name | Properties | Description |
---|---|---|
page-change | page number - updated page | on pagination page change event |
dblclick | row typeof data - row dataindex number - index of clicked rowevent Event - native click event | on row double click event |
mouseenter | row typeof data - row dataindex number - index of clicked rowevent Event - native mouseenter event | on row mouseenter event |
mouseleave | row typeof data - row dataindex number - index of clicked rowevent Event - native mouseleave event | on row mouseleave event |
contextmenu | row typeof data - row dataindex number - index of clicked rowevent Event - native contextmenu event | on row right click event |
cell-click | row typeof data - row datacolumn Column - column dataindex number - row indexcolindex number - column indexevent Event - native click event | on cell click event |
update:currentPage | value number - updated currentPage prop | currentPage prop two-way binding |
update:selected | value typeof data - updated select prop | select prop two-way binding |
select | newRow typeof data - new select valueoldRow typeof data - old select value | on row select event |
check | value Array<typeof data> - all checked rowsrow typeof data - row data | on row checked event |
check-all | value Array<typeof data> - all checked rows | on all rows checked event |
update:checkedRows | value Array<typeof data> - updated checkedRows prop | checkedRows prop two-way binding |
sort | column Column - column datadirection string - 'asc' or 'desc'event Event - native event | on column sort change event |
filters-change | filters Record<string, string> - filter object | on filter change event |
filters-event | filtersEvent string - props filtersEvent valuefilters Record<string, string> - filter objectevent Event - native event | on natvie filter event based on props filtersEvent |
update:openedDetailed | value Array<typeof data> - updated openedDetailed prop | openedDetailed prop two-way binding |
details-open | row typeof data - row data | on details open event |
details-close | row typeof data - row data | on details close event |
click | row typeof data - row dataindex number - index of clicked rowevent Event - native click event | on row click event |
dragstart | row typeof data - row dataindex number - index of draged rowevent DragEvent - native dragstart event | on row dragstart event |
dragend | row typeof data - row dataindex number - index of draged rowevent DragEvent - native dragend event | on row dragend event |
drop | row typeof data - row dataindex number - index of draged rowevent DragEvent - native drop event | on row drop event |
dragleave | row typeof data - row dataindex number - index of draged rowevent DragEvent - native dragleave event | on row dragleave event |
dragover | row typeof data - row dataindex number - index of draged rowevent DragEvent - native dragover event | on row dragover event |
columndragstart | column Column - column dataindex number - index of draged columnevent DragEvent - native columndragstart event | on column columndragstart event |
columndragend | column Column - column dataindex number - index of draged columnevent DragEvent - native columndragend event | on column columndragend event |
columndrop | column Column - column dataindex number - index of draged columnevent DragEvent - native columndrop event | on column columndrop event |
columndragleave | column Column - column dataindex number - index of draged columnevent DragEvent - native columndragleave event | on column columndragleave event |
columndragover | column Column - column dataindex number - index of draged columnevent DragEvent - native columndragover event | on column columndragover event |
Slots
Name | Description | Bindings |
---|---|---|
default | Place o-table-column here | |
pagination | Override pagination label | current number - current pageper-page number - rows per pagetotal number - total rows countchange (page: number): void - on page change event |
top-left | Additional slot if table is paginated | |
caption | Define a table caption here | |
preheader | Define preheader content here | |
check-all | Override check all checkbox | is-all-checked boolean - if all rows are checkedis-all-uncheckable boolean - if check all is uncheckablecheck-all (): void - check all function |
detail | Place row detail content here | row unknown - row contentindex number - row index |
empty | Define content if table is empty | |
footer | Define a custom footer | column-count number - counts of visible columnsrow-count number - counts of visible rows |
loading | Override loading component | loading boolean - is loading enabled |
bottom-left | Additional slot if table is paginated |
TableColumn component
html
<o-table-column></o-table-column>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
customSearch | Define a custom funtion for the filter search | (row: unknown, filter: string) => boolean | - | |
customSort | Define a custom sort function | (a: unknown, b: unknown, isAsc: boolean) => number | - | |
field | Define an object property key if data is an object | string | - | |
headerSelectable | Make header selectable | boolean | - | false |
label | Define the column label | string | - | |
meta | Add addtional meta information for the column for custom purpose | string|number|boolean|func|object|array | - | |
numeric | Define column value as number | boolean | - | false |
position | Position of the column content | string | left , centered , right | |
searchable | Enable an additional searchbar below the column header | boolean | - | false |
sortable | Enable column sortability | boolean | - | false |
sticky | Whether the column is sticky or not | boolean | - | false |
subheading | Define a column sub heading | string | - | |
tdAttrs | Adds native attributes to td | (row: unknown, column: typeof props) => object | - | Default function (see source code) |
thAttrs | Adds native attributes to th | (column: typeof props) => object | - | Default function (see source code) |
visible | Define whether the column is visible or not | boolean | - | true |
width | Column fixed width | number|string | - |
Slots
Name | Description | Bindings |
---|---|---|
default | Default Slot | row unknown - row datacolumn Column - column definitionindex number - row indexcolindex number - column indextoggle-details (row): void - toggle details function |
header | Override header label | column Column - column definitionindex number - column index |
subheading | Override subheading label | column Column - column definitionindex number - column index |
searchable | Override searchable input | column Column - column definitionindex number - column indexfilters Record<string,string> - active filters object |
Sass variables
Current theme ➜ Oruga Base
SASS Variable | Default |
---|---|
$table-background-color | #fff |
$table-background | #f5f5f5 |
$table-boder | 1px solid transparent |
$table-border-radius | $base-border-radius |
$table-card-box-shadow | 0 2px 3px rgba($black, 0.1), 0 0 0 1px rgba($black, 0.1) |
$table-card-cell-font-weight | 600 |
$table-card-cell-padding | 0 0.5em 0 0 |
$table-card-cell-text-align | left |
$table-card-detail-margin | -1rem 0 0 0 |
$table-card-margin | 0 0 1rem 0 |
$table-color | black |
$table-current-sort-border-color | $grey |
$table-current-sort-font-weight | 700 |
$table-current-sort-hover-border-color | $grey |
$table-detail-background | #fafafa |
$table-detail-box-shadow | inset 0 1px 3px $grey |
$table-detail-chevron-color | $primary |
$table-detail-chevron-width | 40px |
$table-detail-padding | 1rem |
$table-focus-border-color | $primary |
$table-focus-box-shadow | 0 0 0 0.125em rgba($primary, 0.25) |
$table-hoverable-background-color | #fafafa |
$table-narrow-padding | 0.25em 0.5em |
$table-row-active-background-color | $primary |
$table-row-active-color | $primary-invert |
$table-sticky-header-height | 300px |
$table-sticky-zindex | 1 |
$table-striped-background-color | #fafafa |
$table-td-border | 1px solid $grey-lighter |
$table-td-padding | 0.5em 0.75em |
$table-th-border | 2px solid $grey-lighter |
$table-th-checkbox-width | 40px |
$table-th-color | #363636 |
$table-th-detail-width | 14px |
$table-th-font-weight | 600 |
$table-th-padding | 0.5em 0.75em |
See ➜ 📄 Full scss file
Current theme ➜ Oruga Full
SASS Variable | Default |
---|---|
$table-background-color | #fff |
$table-background | #f5f5f5 |
$table-boder | 1px solid transparent |
$table-border-radius | $base-border-radius |
$table-card-box-shadow | 0 2px 3px rgba($black, 0.1), 0 0 0 1px rgba($black, 0.1) |
$table-card-cell-font-weight | 600 |
$table-card-cell-padding | 0 0.5em 0 0 |
$table-card-cell-text-align | left |
$table-card-detail-margin | -1rem 0 0 0 |
$table-card-margin | 0 0 1rem 0 |
$table-color | black |
$table-current-sort-border-color | $grey |
$table-current-sort-font-weight | 700 |
$table-current-sort-hover-border-color | $grey |
$table-detail-background | #fafafa |
$table-detail-box-shadow | inset 0 1px 3px $grey |
$table-detail-chevron-color | $primary |
$table-detail-chevron-width | 40px |
$table-detail-padding | 1rem |
$table-focus-border-color | $primary |
$table-focus-box-shadow | 0 0 0 0.125em rgba($primary, 0.25) |
$table-hoverable-background-color | #fafafa |
$table-narrow-padding | 0.25em 0.5em |
$table-row-active-background-color | $primary |
$table-row-active-color | $primary-invert |
$table-sticky-header-height | 300px |
$table-sticky-zindex | 1 |
$table-striped-background-color | #fafafa |
$table-td-border | 1px solid $grey-lighter |
$table-td-padding | 0.5em 0.75em |
$table-th-border | 2px solid $grey-lighter |
$table-th-checkbox-width | 40px |
$table-th-color | #363636 |
$table-th-detail-width | 14px |
$table-th-font-weight | 600 |
$table-th-padding | 0.5em 0.75em |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
The theme does not have any custom variables for this component.
Current theme ➜ Bootstrap
SASS Variable | Default |
---|---|
$table-head-bg | initial |
$table-head-color | initial |
$table-head-border-width | var(--#{$prefix}border-width) |
$table-sticky-zindex | 1 |
$table-sticky-bg | initial |
$table-sticky-color | initial |
$table-detail-padding | 0.5rem 0.75rem |
$table-detail-bg | var(--#{$prefix}gray-light) |
$table-sortable-hover-border-color | var(--#{$prefix}secondary) |
$table-current-sort-bg | var(--#{$prefix}gray-light) |
$table-focus-color | var(--#{$prefix}-info-rgb) |
$table-card-spacer | $spacer |
See ➜ 📄 Full scss file