Skip to content

Table

The BTable component can be used to display data in a tabular format. It has built in sorting and pagination functionality.

Basic usage

In it's simplest form you can pass an array of objects to the rows prop and an array of objects to the cols prop. The cols prop is used to define the headings and what data and order to display in each column. The rows prop is used to define the data to display in each row.

Name
City
Country
Phone
ID
JohnNew YorkUSA+1 555 1234561
JaneLondonUK+44 555 1234562
BobParisFrance+33 555 1234563
AliceBerlinGermany+49 555 1234564
HansMunichGermany+49 555 1234565
LoveUmeåSweden+49 555 1234566
HateUmeåSweden7

Alignment and styling

By default headings and cells are left aligned as this is easier to read than center or left aligned text. The exceptions to this is columns with numeric content which are easier to read and compare when right aligned. You can change the default alignment by setting the numeric field to true for the column. This will right align that columns data and center the heading.

Name
City
Age
Income
JohnNew York1201000
JaneLondon2412000
BobParis31110000
AliceBerlin1932
HansMunich2999000
LoveUmeå3100000
HateUmeå3

Styling and slots

There are a number of dynamic slots available to allow you to customize the table. The header-<column key>} slot allows you to customize the table headings. The cell-<column key> slot allows you to customize the table cells.

Name
City
Income
Actions
JohnNew York
1000
JaneLondon
12000
BobParis
110000
AliceBerlin
32
HansMunich
99000
LoveUmeå
100000
HateUmeå

The body slot

The body slot allows you to customize the whole table body. This is useful if the default row implementation does not meet your needs. For example you could add expandable rows or a row with a form to edit data.

Name
City
Income
Actions
John New York 1000
Jane London 12000
Bob Paris 110000
Alice Berlin 32
Hans Munich 99000
Love Umeå 100000
Hate Umeå

Not really.