# Table ## Introduction Table description. ## Guidance Find out when to use the table component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/table). ## Quick start examples ### Table [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/table/preview) #### Markup
January £85 £95
February £75 £55
March £165 £125
#### Macro {% from "table/macro.njk" import govukTable %} {{ govukTable({ "rows": [ [ { "text": "January" }, { "text": "£85", "format": "numeric" }, { "text": "£95", "format": "numeric" } ], [ { "text": "February" }, { "text": "£75", "format": "numeric" }, { "text": "£55", "format": "numeric" } ], [ { "text": "March" }, { "text": "£165", "format": "numeric" }, { "text": "£125", "format": "numeric" } ] ] }) }} ### Table table with head [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/table/table-with-head/preview) #### Markup
Month you apply Rate for bicycles Rate for vehicles
January £85 £95
February £75 £55
March £165 £125
#### Macro {% from "table/macro.njk" import govukTable %} {{ govukTable({ "head": [ { "text": "Month you apply" }, { "text": "Rate for bicycles", "format": "numeric" }, { "text": "Rate for vehicles", "format": "numeric" } ], "rows": [ [ { "text": "January" }, { "text": "£85", "format": "numeric" }, { "text": "£95", "format": "numeric" } ], [ { "text": "February" }, { "text": "£75", "format": "numeric" }, { "text": "£55", "format": "numeric" } ], [ { "text": "March" }, { "text": "£165", "format": "numeric" }, { "text": "£125", "format": "numeric" } ] ] }) }} ### Table table with head and caption [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/table/table-with-head-and-caption/preview) #### Markup
Caption 1: Months and rates
Month you apply Rate for bicycles Rate for vehicles
January £85 £95
February £75 £55
March £165 £125
#### Macro {% from "table/macro.njk" import govukTable %} {{ govukTable({ "caption": "Caption 1: Months and rates", "captionClasses": "govuk-heading-m", "firstCellIsHeader": true, "head": [ { "text": "Month you apply" }, { "text": "Rate for bicycles", "format": "numeric" }, { "text": "Rate for vehicles", "format": "numeric" } ], "rows": [ [ { "text": "January" }, { "text": "£85", "format": "numeric" }, { "text": "£95", "format": "numeric" } ], [ { "text": "February" }, { "text": "£75", "format": "numeric" }, { "text": "£55", "format": "numeric" } ], [ { "text": "March" }, { "text": "£165", "format": "numeric" }, { "text": "£125", "format": "numeric" } ] ] }) }} ## Requirements ### Build tool configuration When compiling the Sass files you'll need to define includePaths to reference the node_modules directory. Below is a sample configuration using gulp .pipe(sass({ includePaths: 'node_modules/' })) ### Static asset path configuration In order to include the images used in the components, you need to configure your app to show these assets. Below is a sample configuration using Express js: app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/assets'))) ## Component options Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text. See [options table](https://design-system.service.gov.uk/components/table/#options-example-default) for details. ### Setting up Nunjucks views and paths Below is an example setup using express configure views: nunjucks.configure('node_modules/govuk-frontend/components', { autoescape: true, cache: false, express: app }) ## Contribution Guidelines can be found at [on our Github repository.](https://github.com/alphagov/govuk-frontend/blob/master/CONTRIBUTING.md "link to contributing guidelines on our github repository") ## License MIT