Skip to content

Table ​

WARNING

This component is still under development. It is not yet available in releases of Codex.

Demos ​

Default ​

Default table
Column 1Column 2Column 3
OneTwoThree
123
FourFiveSix
456
NameValue
View
Reading direction

Exploring content and width options ​

With set column widths ​

In this demo, the second column is set to be wider than the first and third columns. You can set column widths to a percentage or specific value if table-layout: fixed is used.

This is done via CSS in the parent component here. However, we might consider building this into the columns prop for additional ease.

Table with set column widths
Column 1Column 2Column 3
OneTwoThree
123
FourFiveSix
456
NameValue
View
Reading direction

With varied content length ​

In this table, the third column's content is much longer than the other two. The column widths are naturally set accordingly. However, when you look at the table on a mobile device, the third column will be uncomfortably narrow. This could be fixed by adding a min width as demonstrated below.

Table with varied content length
UserIP(s)User Agent(s)
Abc123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Twoword Username123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Shortish123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
123.45.6.789123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Short123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
PascalCase123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
NameValue
View
Reading direction

With many columns ​

This table has a lot of columns, including two with long content. Horizontal scrolling occurs since the natural state of this table is wider than the container.

Table with many columns
UserIP(s)User Agent(s)User 2IP(s) 2User Agent(s) 2
Abc123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Abc123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Twoword Username123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Twoword Username123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Shortish123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Shortish123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
123.45.6.789123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]123.45.6.789123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Short123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Short123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
PascalCase123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]PascalCase123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
NameValue
View
Reading direction

With many columns and column min-widths ​

This is the same table as above, but a min-width is set on the two columns with longer content to make it more readable.

Table with many columns, improved
UserIP(s)User Agent(s)User 2IP(s) 2User Agent(s) 2
Abc123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Abc123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Twoword Username123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Twoword Username123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Shortish123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Shortish123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
123.45.6.789123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]123.45.6.789123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
Short123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]Short123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
PascalCase123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]PascalCase123.45.6.789Mozilla/5.0 (Windows NT 10.0; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 [10]
NameValue
View
Reading direction

Customizing content with slots ​

Customizing cells ​

You can customize cell content by using dynamically generated slots for each column. The name of a column's slot follows the format item-[COLUMN_ID]. For example, in the table below, the slot to customize the "Name" column, which has an id of name, is item-name. You can put markup or even components inside these slots.

Table using item slots
NameStatusLanguage
JavaScript modulo 2
Connected
javascript
Composite modulo 2
Connected
Composition
number is even, python
Disconnected
python
NameValue
View
Reading direction

Customizing the table body ​

Instead of passing table data in via the data prop, you can use the default slot of the Table component to customize the table body, while continuing to use the columns prop to pass in column information. This is useful when you want custom formatting or structure in the table body, but still want to take advantage of features built into the Table component's header, like sorting.

Table using the default slot and columns prop
Column 1Column 2Column 3
First section
OneTwoThree
123
Second section
FourFiveSix
456
NameValue
View
Reading direction

Customizing all table content ​

Instead of passing data and column information in via props, you can use the default slot of the Table component to build your own table structure with all valid table elements. This can be useful for customizing table structure, like adding cells that span multiple rows or columns.

Table using the default slot
Season/seriesDoctorEpisodesOriginally airedAverage viewers (millions)
First airedLast aired
Classic era
Season 1First Doctor4223 November 196312 September 19648.08
Season 23931 October 196424 July 196510.46
Season 34511 September 196516 July 19667.65
Season 4Second Doctor4310 September 19661 July 19677.1
Season 5402 September 19671 June 19687.23
Season 64510 August 196821 June 19696.38
NameValue
View
Reading direction

Vue usage ​

Props ​

Prop nameDescriptionTypeDefault
caption(required)Table caption. TODO: add prop to make this visually-hiddenstring
columnsTableColumn[]() => { return []; }
dataarray[]

Slots ​

NameDescriptionBindings
'item-' + columnIdTable cell content, per column.
item mixed - Data for the cell
defaultCustom thead, tbody, and tfoot.