Components
Table
Use the table component to make information easier to compare and scan for users.
Children are the body rows.
Read the Design System guidance for table
Import
import * as Table from 'govuk-react/table';Examples
Default
Code
<Table.Composite
caption="Dates and amounts"
captionSize="m"
head={(
<>
<Table.ColumnHeader>Date</Table.ColumnHeader>
<Table.ColumnHeader>Amount</Table.ColumnHeader>
</>
)}
>
{(
<>
<Table.Row>
<Table.RowHeader>First 6 weeks</Table.RowHeader>
<Table.Cell>£109.80 per week</Table.Cell>
</Table.Row>
<Table.Row>
<Table.RowHeader>Next 33 weeks</Table.RowHeader>
<Table.Cell>£109.80 per week</Table.Cell>
</Table.Row>
<Table.Row>
<Table.RowHeader>Total estimated pay</Table.RowHeader>
<Table.Cell>£4,282.20</Table.Cell>
</Table.Row>
</>
)}
</Table.Composite>Numbers in a table
Code
<Table.Composite
caption="Months and rates"
captionSize="m"
head={(
<>
<Table.ColumnHeader>Month you apply</Table.ColumnHeader>
<Table.ColumnHeader numeric>Rate for bicycles</Table.ColumnHeader>
<Table.ColumnHeader numeric>Rate for vehicles</Table.ColumnHeader>
</>
)}
>
{(
<>
<Table.Row>
<Table.RowHeader>January</Table.RowHeader>
<Table.Cell numeric>£85</Table.Cell>
<Table.Cell numeric>£95</Table.Cell>
</Table.Row>
<Table.Row>
<Table.RowHeader>February</Table.RowHeader>
<Table.Cell numeric>£75</Table.Cell>
<Table.Cell numeric>£55</Table.Cell>
</Table.Row>
<Table.Row>
<Table.RowHeader>March</Table.RowHeader>
<Table.Cell numeric>£165</Table.Cell>
<Table.Cell numeric>£125</Table.Cell>
</Table.Row>
</>
)}
</Table.Composite>Custom column widths
Code
<Table.Composite
caption="Month you apply"
captionSize="m"
head={(
<>
<Table.ColumnHeader className={overrideClasses({ width: 'one-half' })}>Date</Table.ColumnHeader>
<Table.ColumnHeader className={overrideClasses({ width: 'one-quarter' })}>Rate for vehicles</Table.ColumnHeader>
<Table.ColumnHeader className={overrideClasses({ width: 'one-quarter' })}>Rate for bicycles</Table.ColumnHeader>
</>
)}
>
{(
<Table.Row>
<Table.RowHeader>First 6 weeks</Table.RowHeader>
<Table.Cell>£109.80 per week</Table.Cell>
<Table.Cell>£159.80 per week</Table.Cell>
</Table.Row>
)}
</Table.Composite>API reference
Table.Root
Use the table component to make information easier to compare and scan for users.
| Prop | Type |
|---|---|
smallTextUntilTablet | boolean |
Table.Body
No props of its own. Other props are passed to the element it renders.
Table.Caption
| Prop | Type |
|---|---|
size | "m" | "l" | "xl" |
Table.Cell
| Prop | Type |
|---|---|
numeric | boolean |
Table.ColumnHeader
| Prop | Type |
|---|---|
numeric | boolean |
Table.Composite
Use the table component to make information easier to compare and scan for users.
Children are the body rows.
| Prop | Type |
|---|---|
smallTextUntilTablet | boolean |
captionCaption text. | ReactNode |
captionSize | "m" | "l" | "xl" |
headCan be used to add a row of table header cells ( | ReactNode |
Table.Head
No props of its own. Other props are passed to the element it renders.
Table.Header
| Prop | Type |
|---|---|
numeric | boolean |
Table.Row
No props of its own. Other props are passed to the element it renders.
Table.RowHeader
| Prop | Type |
|---|---|
numeric | boolean |