Skip to content

Table - Web Component

The Table component can be used imported from:

Playground

Parameters

...

Slots

This component has slots. Check the documentation about how to use the slots.

NameTagsDescription
defaulttable

Parameters use

headers

The headers attribute is used to define the table headers.

You can pass an array of numbers or string (number | string)[]:

We can use the head-<index> slots to customize content:

Info
Configured headers

But there's an option of passing config objects if each row of the table is going to represent an object. In this case, rows will be the array of key-value pairs objects and headers an array of these config objects where we choose the property of the object that will go in that column (prop) and a name or text for that column (text):

rows

The rows attribute is used to define the table rows.

Like the headers attribute, you can pass either pass a matrix of numbers or string (number | string)[][]:

We can use the cell-<row>-<index> slots to customize content:

Cell prop
Object rows

rows can also be objects, and in that case, the properties will be displayed in order per column:

We can use the cell-<row>-<prop> slots to customize content:

Cell prop

caption

The caption attribute is used to define the table caption.

Using embedded table

You can also embed and entire table component. For this, a <table> tag needs to be placed inside:

Head 1Head 2Head 3
Cell 1-1Cell 1-2Cell 1-3
Cell 2-1Cell 2-2Cell 2-3

Rows

...

zebra

We can use the zebra attribute to set a highlighted background in the even rows:

Using zebra="odd" will apply it to odd ones:

This will work too with embed tables:

Cell 1-1Cell 1-2Cell 1-3
Cell 2-1Cell 2-2Cell 2-3
Cell 3-1Cell 3-2Cell 3-3

Cells

config

The config attribute in <td> or <th> tags can change the positioning of the content:

LeftCenterRight
highlight

We can highlight entire columns using the bg property on the headers configuration:

You can also force this color by using an string:

Alternatively, we can do it in the embed table just placing the highlight attribute in the header of the corresponding column:

Head 1Head 2Head 3
Cell 1Cell 2Cell 3

Dynamic tables

The embed table allow us to have full control of the table or even use other components inside:

Sel.NamePriceQt.Total
Item name 1
Item name 2
Item name 3
Total:

Browser support

Detected engine:  

  • Chromium

  • Webkit

  • Gecko

HTML Examples

CodeSandbox example