# @govuk-frederic/table

> Renders a table with optional heading row. Cell data is derived from an array and can include names per cell or per row.

Latest version **0.2.0** (published 2019-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @govuk-frederic/table
pnpm add @govuk-frederic/table
yarn add @govuk-frederic/table
bun add @govuk-frederic/table
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2019-02-13 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 147.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Steve Sims |
| Maintainers | loque-, penx, petelockey, steve_sims |

## Links

- npm: https://www.npmjs.com/package/@govuk-frederic/table
- Homepage: https://github.com/stevesims/govuk-frederic/tree/master/components/table
- npm.io page: https://npm.io/package/@govuk-frederic/table

## Dependencies (2)

- [@govuk-react/hoc](https://npm.io/package/@govuk-react/hoc.md) ^0.6.0-alpha.1
- [@govuk-react/constants](https://npm.io/package/@govuk-react/constants.md) ^0.6.0-alpha.1

## Recent versions

- 0.2.0 (latest) — 2019-02-13
- 0.1.3 — 2018-11-08
- 0.1.1 — 2018-08-24
- 0.1.0 — 2018-08-21
- 0.0.6 — 2018-08-13
- 0.0.5 — 2018-08-13
- 0.0.4 — 2018-08-07
- 0.0.3 — 2018-07-30
- 0.0.2 — 2018-07-17

## README

Table
=====

### Import
```js
  import Table from '@govuk-frederic/table';
```
<!-- STORY -->

### Usage

Simple
```jsx
const arrayExampleHeadings = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4'];
const arrayExampleContent = [
 ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
 ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
 ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];
const columnTableNames = ['one', 'two', 'three', ['i', 'am', 'named', 'individually']];

<Table titles={arrayExampleHeadings} rows={arrayExampleContent} names={columnTableNames} />
```

rowIncludesHeading
```jsx
const arrayExampleHeadings = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4'];
const arrayExampleContent = [
 ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
 ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
 ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];
const rowTableNamesWithTitles = ['heading', 'one', ['i', 'am', 'named', 'individually'], 'three'];

<Table titles={arrayExampleHeadings} rows={arrayExampleContent} rowIncludesHeading nameByRow names={rowTableNamesWithTitles} />
```

rowIncludesHeading, no titles
```jsx
const arrayExampleHeadings = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4'];
const arrayExampleContent = [
 ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
 ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
 ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];
const rowTableNames = ['one', ['i', 'am', 'named', 'individually'], 'three'];

<Table rows={arrayExampleContent} rowIncludesHeading nameByRow names={rowTableNames} />
```

rowIncludesHeading, no titles, small single row
```jsx
const arrayExampleHeadings = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4'];
const arrayExampleContent = [
 ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
 ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
 ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];
const rowTableNames = ['one', ['i', 'am', 'named', 'individually'], 'three'];

<Table rows={[['title', 'value']]} rowIncludesHeading nameByRow names={rowTableNames} />
```

rowIncludesHeading, with titles, with flexible columns
```jsx
const arrayExampleHeadings = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4'];
const arrayExampleContent = [
 ['Content 1-1', 'Content 1-2', 'Content 1-3', 'Content 1-4'],
 ['Content 2-1', 'Content 2-2', 'Content 2-3', 'Content 2-4'],
 ['Content 3-1', 'Content 3-2', 'Content 3-3', 'Content 3-4'],
];
const rowTableNamesWithTitles = ['heading', 'one', ['i', 'am', 'named', 'individually'], 'three'];

<Table titles={arrayExampleHeadings} rows={arrayExampleContent} flexibleColumns rowIncludesHeading nameByRow names={rowTableNamesWithTitles} />
```

### Properties
Prop | Required | Default | Type | Description
:--- | :------- | :------ | :--- | :----------
 `borderless` |  | ```false``` | bool | 
 `flexibleColumns` |  | ```false``` | bool | 
 `name` |  | `````` | string | 
 `nameByRow` |  | ```false``` | bool | 
 `names` |  | ```[]``` | arrayOf[object Object] | 
 `rowIncludesHeading` |  | ```false``` | bool | 
 `rows` | true | `````` | arrayOf[object Object] | 
 `spacing` |  | ```SPACING.SCALE_3``` | string | 
 `titles` |  | ```null``` | arrayOf[object Object] |

---
_Source: https://npm.io/package/@govuk-frederic/table · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
