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 |
---|---|---|---|---|
John | New York | USA | +1 555 123456 | 1 |
Jane | London | UK | +44 555 123456 | 2 |
Bob | Paris | France | +33 555 123456 | 3 |
Alice | Berlin | Germany | +49 555 123456 | 4 |
Hans | Munich | Germany | +49 555 123456 | 5 |
Love | Umeå | Sweden | +49 555 123456 | 6 |
Hate | Umeå | Sweden | 7 |
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 |
---|---|---|---|
John | New York | 120 | 1000 |
Jane | London | 24 | 12000 |
Bob | Paris | 31 | 110000 |
Alice | Berlin | 19 | 32 |
Hans | Munich | 29 | 99000 |
Love | Umeå | 3 | 100000 |
Hate | Umeå | 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 |
---|---|---|---|
John | New York | 1000 | |
Jane | London | 12000 | |
Bob | Paris | 110000 | |
Alice | Berlin | 32 | |
Hans | Munich | 99000 | |
Love | Umeå | 100000 | |
Hate | Umeå |
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å |