Sha256: 581c5300f872893e4e6c71046dda24a26b537f51a0244633dbcf14113f0e00ed

Contents?: true

Size: 2 KB

Versions: 15

Compression:

Stored size: 2 KB

Contents

# Error message

## Introduction

Component to show a red error message - used for form validation. Use inside a label or legend.

## Guidance

Find out when to use the error message component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/error-message).

## Quick start examples

### Error message

[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/error-message/preview)

#### Markup

    <span class="govuk-error-message">
      Error message about full name goes here
    </span>

#### Macro

    {% from "error-message/macro.njk" import govukErrorMessage %}

    {{ govukErrorMessage({
      "text": "Error message about full name goes here"
    }) }}

## 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/error-message/#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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
govuk_publishing_components-12.20.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.19.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.18.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.17.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.16.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.15.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.14.1 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.14.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.13.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.12.1 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.12.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.11.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.10.0 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.9.1 node_modules/govuk-frontend/components/error-message/README.md
govuk_publishing_components-12.9.0 node_modules/govuk-frontend/components/error-message/README.md